What C# is

C# (pronounced "C sharp") is a general-purpose programming language created by Microsoft. It is used for web applications and APIs, cloud services, desktop and mobile apps, games and command-line tools. A few properties shape how it feels:

  • Statically typed. Every variable has a type that is fixed when you write the code, and the compiler checks every use of it before the program runs. See static and dynamic typing.
  • Strongly typed. C# does not quietly turn text into numbers or numbers into true/false; conversions that could lose information must be written out.
  • Object-oriented, with functional features. Code is organized in classes and other types (see Object-Oriented Concepts), and functions can be passed around as values, as in LINQ.
  • Managed. A garbage collector frees memory you no longer use, so you never release memory by hand (see garbage collection).
  • Compiled. A compiler translates the whole program before it runs, and refuses programs with type errors.

Here is a complete C# program. It works out the average of some daily meter readings:

// Daily electricity use (kWh) of one Kestrel Energy household
double[] readings = [11.2, 9.8, 12.5, 10.1, 13.4];

double total = 0;
foreach (double kwh in readings)
{
    total = total + kwh;
}

double average = total / readings.Length;
Console.WriteLine($"Days measured: {readings.Length}");
Console.WriteLine($"Average per day: {average:F1} kWh");
Days measured: 5
Average per day: 11.4 kWh

Blocks are marked with curly braces { }, statements end with a semicolon, // starts a comment, and Console.WriteLine prints a line. Each variable is declared with its type: double is a floating-point number and double[] an array of them. The $"…" string fills in the values between braces; :F1 asks for one decimal. The next page, The .NET SDK, the dotnet CLI and Your First Program, shows how to run a file like this.

Because the types are known in advance, the compiler catches a whole class of mistakes before anyone runs the program. Assigning text to a number is one of them; this program never starts:

int customersAffected = "1250";
Console.WriteLine(customersAffected);
example.cs(1,25): error CS0029: Cannot implicitly convert type 'string' to 'int'

The message names the file, the line and column ((1,25)), an error code you can look up (CS0029) and a description. In Python or JavaScript the same mistake would only show up when that line runs, and perhaps not at all.

A short history

Microsoft announced C# on 26 June 2000, as part of its new .NET platform, and in the same announcement said it had submitted the language to Ecma International for standardization. Anders Hejlsberg, who earlier created Turbo Pascal and Delphi (and later led the design of TypeScript), was its chief designer. C# 1.0 shipped in January 2002 with Visual Studio .NET 2002.

The language has grown steadily since. Since C# 9 a new version appears every November, together with a new .NET release:

Version Released What it brought (selection)
C# 1.0 Jan 2002 Classes, structs, interfaces, properties, events, delegates
C# 2.0 Nov 2005 Generics, nullable value types, iterators
C# 3.0 Nov 2007 LINQ, lambda expressions, var, extension methods
C# 5.0 Aug 2012 async and await
C# 6.0 Jul 2015 String interpolation, ?., nameof; the new open-source Roslyn compiler
C# 7.0 Mar 2017 Tuples, pattern matching, local functions
C# 8.0 Sep 2019 Nullable reference types, switch expressions, using declarations
C# 9 Nov 2020 Records, init, top-level statements
C# 10 – 13 Nov 2021 – Nov 2024 File-scoped namespaces, raw string literals, required, list patterns, primary constructors, collection expressions
C# 14 Nov 2025 Extension members, the field keyword, null-conditional assignment

As of October 2026, C# 14 is the current version and the default with .NET 10. C# 15 is in preview with .NET 11 (release candidate 1 appeared on 8 September 2026); its preview documentation lists features such as union types, but the final feature set is only fixed when .NET 11 is released, expected in November 2026.

The C# standard

C# is standardized as ECMA-334. The current edition, the 7th (December 2023), describes C# 7; the matching ISO standard is ISO/IEC 20619:2023. The standard trails the language: new features are first described in Microsoft's language reference and specification proposals, and the official compiler (Roslyn) is what decides in practice. You will rarely need the standard itself, but it is why other compilers, such as Mono's, could be written.

.NET Framework and modern .NET

.NET is the platform C# programs run on: a runtime that executes compiled code, a large set of class libraries, and the tools to build, test and publish programs. It also runs other languages, notably F# and Visual Basic, but C# is by far the most used. The name ".NET" covers two product lines, and the difference matters when you read documentation or job ads.

  • .NET Framework is the original implementation, released in 2002. It runs only on Windows and is part of Windows itself. Its last version, 4.8.1 (August 2022), is still supported for as long as the Windows version it is installed on, but it gets security and reliability fixes only, no new features. Many older business applications, Windows services and Windows PowerShell 5.1 run on it.
  • Modern .NET started in 2016 as .NET Core: a rewrite that is open source (MIT license) and cross-platform, running on Windows, Linux and macOS, on x64 and Arm processors. With version 5 (November 2020) the word "Core" was dropped from the name, and version 4 was skipped to avoid confusion with .NET Framework 4.x. Everything new — .NET 8, 9, 10 — belongs to this line.
.NET Framework Modern .NET
Versions 1.0 – 4.8.1 .NET Core 1.0 – 3.1, then .NET 5, 6, 7 … 10
Operating systems Windows only Windows, Linux, macOS
Source Closed (reference source published) Open source, developed on GitHub
Newest C# C# 7.3 officially The latest (C# 14 on .NET 10)
Status Maintained, no new features New release every November

How C# code runs

Running a C# program takes two translation steps, one before the program runs and one while it runs.

  1. The C# compiler, called Roslyn, reads your .cs files, checks the types and translates the program into Intermediate Language (IL, also called CIL, Common Intermediate Language): compact instructions for an imaginary processor, independent of the real processor and operating system. The IL is stored in an assembly, a .dll file, together with metadata that describes every type and method.
  2. When the program starts, the Common Language Runtime (CLR) loads the assembly. Its just-in-time (JIT) compiler translates each method to machine code for the actual processor the first time the method is called. The CLR also manages memory with its garbage collector, checks types at run time, and turns errors into exceptions.
From source code to machine code. At build time, the C# compiler (Roslyn) turns the source file Program.cs into Intermediate Language, stored in an assembly (a .dll file). At run time, the Common Language Runtime loads the assembly; its JIT compiler turns the IL into machine code for the actual processor, and the garbage collector manages memory. Build time Run time Source code Program.cs C# compiler Roslyn IL + metadata app.dll CLR JIT compiler garbage collector loads assemblies Machine code
The compiler runs once, when you build; the JIT compiler runs on the user's machine, method by method, while the program runs.

This design is close to Java's (bytecode plus a virtual machine) and different from Python's, where an interpreter reads the code when you run it. It has two practical effects. The same .dll runs on any operating system and processor that has a .NET runtime. And a program starts slightly slower than a fully compiled one, because methods are compiled on first use. For programs where that matters, .NET can also compile everything to a native executable in advance (Native AOT, ahead-of-time compilation), with some restrictions; see Projects, NuGet and Building.

Compile-time and run-time errors

The compiler can only check what it knows while building. It knows that "1250" is a string, so assigning it to an int is refused, as shown above. It cannot know what a user will type or what a file will contain. Converting text to a number therefore compiles fine and fails only when the program runs with bad input; the CLR then throws an exception:

string fromMeterFile = "12.5 kWh";   // read at run time
Console.WriteLine("Parsing the reading...");
double reading = double.Parse(fromMeterFile);
Console.WriteLine(reading);
Parsing the reading...
Unhandled exception. System.FormatException: The input string '12.5 kWh' was not in a correct format.

"Unhandled exception" means nothing caught the error, so the program stopped. Static typing removes many errors, not all of them; Exceptions and Error Handling shows how to handle the rest.

The base class library

Every .NET installation comes with the base class library (BCL): thousands of ready-made types for text, numbers, dates, collections, files, networking, JSON and more. The types are grouped in namespaces such as System, System.IO and System.Text.Json. A using line at the top of a file lets you write the short type name instead of the full one; the most common namespaces are imported automatically.

using System.Globalization;

// Math, strings, dates and cultures: all from the base class library
decimal monthlyCost = 87.456m;
Console.WriteLine(Math.Round(monthlyCost, 2));

string[] regions = ["North", "East", "South"];
Console.WriteLine(string.Join(" | ", regions));

DateOnly readingDay = new DateOnly(2026, 10, 3);
Console.WriteLine(readingDay.DayOfWeek);

CultureInfo dutch = new CultureInfo("nl-NL");
Console.WriteLine(monthlyCost.ToString("C", dutch));
87.46
North | East | South
Saturday
€ 87,46

The keywords of the language are names for library types. The C# keyword int is the .NET type System.Int32, and string is System.String. The same types are available to every .NET language, and to PowerShell:

Console.WriteLine(typeof(int).FullName);
Console.WriteLine(typeof(long).FullName);
Console.WriteLine(typeof(decimal).FullName);
Console.WriteLine(typeof(string).FullName);
Console.WriteLine(int.MaxValue);
System.Int32
System.Int64
System.Decimal
System.String
2147483647

Beyond the base class library, more than 500,000 packages are published on NuGet, the .NET package registry, as of 2026. How to add one to a project is covered in Projects, NuGet and Building.

Versions and support

A new major version of .NET is released every November. Microsoft supports each version for a fixed time, during which it receives monthly patches, including security fixes, on Patch Tuesday:

  • A long-term support release (LTS) is supported for 36 months. Even-numbered versions (.NET 8, .NET 10) are LTS. Choose LTS for production systems you do not want to upgrade every year.
  • A standard-term support (STS) release is supported for 24 months. Odd-numbered versions (.NET 9, .NET 11) are STS. They bring new features a year earlier.
Version Type Released End of support
.NET 11 STS Release candidate since 8 Sep 2026 —
.NET 10 LTS 11 Nov 2025 14 Nov 2028
.NET 9 STS 12 Nov 2024 10 Nov 2026
.NET 8 LTS 14 Nov 2023 10 Nov 2026

The table shows the situation in October 2026. Note that .NET 8 and .NET 9 reach end of support on the same day: applications on either version should move to .NET 10 before 10 November 2026. A short program can do the date arithmetic:

DateOnly today = new DateOnly(2026, 10, 3);
DateOnly net8End = new DateOnly(2026, 11, 10);
DateOnly net10End = new DateOnly(2028, 11, 14);

int daysLeftNet8 = net8End.DayNumber - today.DayNumber;
int daysLeftNet10 = net10End.DayNumber - today.DayNumber;

Console.WriteLine($".NET 8:  {daysLeftNet8} days of support left");
Console.WriteLine($".NET 10: {daysLeftNet10} days of support left");
.NET 8:  38 days of support left
.NET 10: 773 days of support left

.NET Framework follows a different policy: version 4.8 and 4.8.1 have no fixed end date and are supported as long as the Windows version they run on. Older versions retire on their own dates; for example 4.6.2 ends on 12 January 2027.

Where C# is used

  • Web applications and APIs with ASP.NET Core, the web framework of modern .NET (see REST APIs).
  • Cloud services, for example Azure Functions and background workers in containers on Linux.
  • Desktop applications for Windows with Windows Forms and WPF, and cross-platform apps for mobile and desktop with .NET MAUI (the successor of Xamarin).
  • Games: Unity, one of the most used game engines, uses C# for game scripts. As of 2026 Unity still uses an older runtime with C# 9, and is moving to modern .NET (version 6.8 is planned to drop the old Mono runtime).
  • Tools and automation: command-line tools, Windows services, and PowerShell 7 itself, which is written in C#.

In the Stack Overflow Developer Survey 2025, 27.8% of all respondents said they had used C# (Python: 57.9%, JavaScript: 66%). The TIOBE Index of September 2026, which measures search-engine popularity, put C# fifth, and named it "language of the year" for 2023 and 2025. C# is especially common in companies that build on Microsoft technology, such as banks, insurers, government and energy companies.

A small taste of what typical business code looks like: a type that describes an outage ticket, and a few tickets processed in a list. Types such as the record below are explained in Records, Structs and Enums.

List<Ticket> tickets =
[
    new Ticket("INC-20417", "North", 1250),
    new Ticket("INC-20418", "East", 85),
    new Ticket("INC-20421", "North", 430),
];

int affected = tickets.Where(t => t.Region == "North").Sum(t => t.Customers);
Console.WriteLine(tickets[0]);
Console.WriteLine($"Customers affected in North: {affected}");

record Ticket(string Id, string Region, int Customers);
Ticket { Id = INC-20417, Region = North, Customers = 1250 }
Customers affected in North: 1680

Learning C# and certification

Microsoft's own documentation on Microsoft Learn is the main reference for C# and .NET, and it includes free beginner courses. The only C# certificate carrying Microsoft's name is Foundational C# with Microsoft, announced in August 2023 and created by freeCodeCamp together with Microsoft. It is free: about 35 hours of training on Microsoft Learn, followed by an 80-question exam on the freeCodeCamp website.

It is not a proctored Microsoft exam and has no Microsoft exam code. The old Microsoft exam 70-483 "Programming in C#" was retired in January 2021 without a direct successor, so material that refers to it is out of date. Pages in this topic that cover the certificate's subjects carry the tag Foundational C#.