Skip to main content

C#

Pronunciation
SEE-SHARP
Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/csharp

In short

C# is a statically typed, object-oriented language that runs on the .NET runtime with garbage collection and is used for web backends, desktop apps, and games.

What is C#?

C# (pronounced "C sharp") is a general-purpose programming language designed at Microsoft by a team led by Anders Hejlsberg, announced in 2000 and released in 2002 as part of the .NET platform. It is mainly object-oriented but has absorbed many functional programming ideas, such as lambdas, pattern matching, and LINQ, a built-in query syntax for filtering and transforming collections. Since 2016, modern .NET has been open source and cross-platform, running on Windows, macOS, and Linux.

C# is statically typed, with local type inference through the var keyword and optional nullable reference types that warn you at compile time when a value might be null. The compiler turns C# into Intermediate Language (IL), a bytecode that the .NET runtime compiles into native machine code with a just-in-time (JIT) compiler, or ahead of time when needed. Memory is managed by a garbage collector, and C# distinguishes reference types (class), which are shared, from value types (struct), which are copied.

C# is used for web backends and APIs, desktop applications, cloud services, business software, and cross-platform mobile apps. It is also a common scripting language inside game engines, where game logic is written in C# while the engine itself runs in native code. The async and await keywords, which many other languages later adopted, were popularized by C#.

Despite the name, C# has more in common with Java than with C or C++. Like Java, it is statically typed, object-oriented, garbage-collected, and compiled to bytecode for a managed runtime. The "#" comes from the musical sharp sign, which raises a note by a half step, hinting at a step up from C++.

Key takeaways

  • C# is statically typed and object-oriented, with many functional features.
  • Code compiles to Intermediate Language (IL) that the .NET runtime turns into machine code.
  • Memory is managed by a garbage collector.
  • It is used for web backends, desktop apps, cloud services, and game scripting.
  • Despite the name, C# has more in common with Java than with C or C++.

Example

Filtering a list with LINQcsharp
// Top-level statements: no Main method needed in modern C#
var numbers = new List<int> { 5, 12, 8, 21, 3 };

// LINQ filters and sorts collections in a query-like style
var bigOnes = numbers.Where(n => n > 6).OrderBy(n => n);

foreach (var n in bigOnes)
{
    Console.WriteLine($"Found {n}");
}

Readers ask

Is C# only for Windows?

No. Modern .NET is open source and cross-platform, so C# programs can run on Windows, macOS, and Linux, including in containers and cloud environments.

What is the difference between C# and Java?

They are similar in design: both are statically typed, object-oriented, garbage-collected languages that run on a managed runtime. They differ in their ecosystems and in details such as C#'s custom value types (struct), properties, and LINQ.

Is C# related to C++?

Only loosely. C# borrows C-style syntax, such as curly braces and semicolons, but it is a separate language with automatic memory management and a managed runtime.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings