The following list tracks the stable (not incubating or in preview) feature changes I deemed most noteworthy.
The list is ongoing and will be updated with every new .NET release. A + marks an added feature, a - marks a removed feature.
Typically C# versions are only supported on the .NET Version they are introduced with or newer. Microsoft has a list of what is considered C# language version default.
The releases that Microsoft will provide Long-Term Support (LTS) for are marked as such, based on the plan that Microsoft publishes. A new major release of .NET is published every year in November. Even numbered releases are LTS releases that get free support and patches for three years. Odd numbered releases are STS releases that get free support and patches for 18 months.
9
released |
November 2024 |
C#13
- ➕
params
collections -
You can now use params with any recognized collection type, including
Span<T>
,ReadOnlySpan<T>
, and types that implementIEnumerable<T>
and have anAdd
method. - ➕ New lock object
-
Add a new type for thread synchronization, the
System.Threading.Lock
type. - ➕ New escape sequence
-
You can use
\e
as a character literal escape sequence for theESCAPE
character, UnicodeU+001B
. - ➕ Method group natural type
- ➕ Implicit index access
-
The implicit "from the end" index operator,
^
, is now allowed in an object initializer expression. - ➕
ref
andunsafe
in iterators and async methods - ➕
allows ref struct
public class C<T> where T : allows ref struct
- ➕
ref struct
interfaces - ➕ More partial members
-
You can declare partial properties and partial indexers in C# 13.
8 LTS
LTS until |
November 2026 |
released |
November 2023 |
C#12
- ➕ Primary constructors
class BankAccount(string accountID, string owner)
- ➕ Collection expressions
string[] names = ["Julia", "Anna", "Thomas"];
// and
string[] allNames = [.. names, .. moreNames];
- ➕ Optional parameters in lambda expressions
var IncrementBy = (int source, int increment = 1) => source + increment;
- ➕ Experimental attribute
[Experimental("1234")]
- ➕ Interceptors
-
Substitute a call to an interceptable method with a call to itself at compile time
7
released |
November 2022 |
C#11
- ➕ Pattern matching enhancements
-
- ➕ List patterns
sequence is [1, 2, 3]
- ➕
Required
members -
Must be initialized by an object initializer. Really important because now you can trust NRTs (nullable reference types) way more.
- ➕ Raw string literals
""" hello """;
- ➕ Newlines in string interpolation expressions
-
The text inside the
{
and}
characters for a string interpolation can now span multiple lines. - ➕ File-local types
-
file
access modifier is scoped to the source
6 LTS
LTS until |
November 2024 |
released |
November 2021 |
-
.NET 6 unifies the SDK, base libraries, and runtime across mobile, desktop, IoT, and cloud apps.
C#10
- ➕ Pattern matching enhancements
-
- ➕ Extended property patterns
-
Nested properties:
{ Prop1.Prop2: pattern }
- ➕ File-scoped namespace declaration
namespace MyNamespace;
// instead of nesting
- ➕ Allow both assignment and declaration in the same deconstruction
(x, int y) = point;
- ➕ Record structs
public record struct Point
{
public double X { get; init; }
public double Y { get; init; }
public double Z { get; init; }
}
- ➕ Improvements of structure types
- ➕ Interpolated string handlers
- ➕ Allow
const
interpolated strings - ➕ global using directives
- ➕ Improvements on lambda expressions
- ➕ Record types can
seal ToString()
- ➕ Improved definite assignment
- ➕ Allow AsyncMethodBuilder attribute on methods
- ➕ CallerArgumentExpression attribute
- ➕ Warning wave 6
-
Any new keywords added for C# will be all lower-case ASCII characters. This warning ensures that none of your types conflict with future keywords.
5
released |
November 2020 |
-
skips "Core" and is now the main implementation of .NET going forward
C#9
- ➕ Pattern matching enhancements
-
- ➕ Relational patterns
-
<
,>
,⇐
, or>=
- ➕ logical patterns
- ➕ Unconstrained type parameter annotations
-
Which makes NRTs (nullable-reference types) much nicer to use
- ➕
Init
only setters
int YearOfBirth { get; init; }
- ➕ Records
record Person(string FirstName);
- ➕ Top-level statements
-
Programs without
Main
methods - ➕
[ModuleInitializer]
- ➕ Target-typed new expressions
-
Write just
new();
when the type is known - ➕ Target-typed conditional expressions
-
M(b ? 1 : 2)
- ➕ Covariant return types
- ➕ Lambda discard parameters
(_, _) => 0
Core 3.1 LTS
LTS until |
November 2022 |
released |
November 2019 |
Core 3.0 LTS
released |
September 2019 |
-
Fits (.NET Standard 2.1 ⇒ 37,118 of the 37,118 APIs)
- ➕ WinForms, WPF on Windows
-
Only on windows.
C#8.0 (only part of core)
- ➕
readonly
members - ➕ Default interface methods
-
Methods in interface can have an implementation now
- ➕ Pattern matching enhancements
-
- ➕
switch
expression - ➕ Property patterns
- ➕
shape switch { { Point: { Y : 100 } } => "Y is 100"};
- ➕ Tuple patterns
(animal, other) switch { (Animal.Bird, _} => "It's a Bird" };
- ➕ Positional patterns
shape switch { Rectangle (100, 100) => "It's a square" };
- ➕ Nullable reference types
-
Aka non-nullable
Person
and nullablePerson?
- ➕
using
declarations -
Don’t require braces, variable is disposed at the end of the scope
- ➕ Static local functions
- ➕
await foreach
- ➕ Indices and ranges
-
..
,start..
,..end
,^start..
etc. - ➕ Null-coalescing assignment
-
??=
- ➕ Enhancement of interpolated verbatim strings
-
$@
combination is still allowed but now also the@$
order.
4.8
released |
August 2019 |
-
The final framework (still stuck at .NET Standard 2.0 ⇒ 32,638 of the 37,118 APIs)
-
C# ⇐ 7.3
Core 2.1 LTS
LTS until |
August 2021 |
released |
May 2018 |
Core 2.0
released |
August 2017 |
-
(.NET Standard 2.0 ⇒ 32,638 of the 37,118 APIs)
C#7.1
- ➕
async
Main method - ➕ Default literal expressions
- ➕ Inferred tuple element names
- ➕ Pattern matching on generic type parameters
if (item is List<T> value)
{
// ...
}
4.7
released |
June 2017 |
-
(.NET Standard 2.0 ⇒ 32,638 of the 37,118 APIs)
-
Visual Studio 2017
C#7
- ➕ Out variables
GetEmployeeDetails(out string EmployeeName);
- ➕ Tuples and deconstruction
var t = ("post office", 3.6);
// and
var (destination, distance) = t;
- ➕ Pattern matching
-
Via
is
operator inif
orswitch
statements. - ➕ Local functions
-
Methods nested in other members
- ➕ Expanded expression bodied members
- ➕ Ref locals
int a = 1;
// and
ref int alias = ref a;
- ➕ Ref returns
- ➕ Discards
-
Use an underscore when you don’t need the variable:
(_, _, area) = city.GetCityInformation(cityName);
- ➕ Binary Literals and Digit Separators
var binaryLiteral = 0b_0010_1010;
// and
var bigNumber = 123_456_789;
- ➕ Throw expressions
string first = args.Length >= 1 ? args[0] : throw new ArgumentException("Please supply at least one argument.");
Core 1
released |
June 2016 |
-
(.NET Standard 1.6 ⇒ 13,501 of the 37,118 APIs)
-
Cross-platform: Runs on Windows, macOS and Linux.
4.6 LTS
LTS until |
January 2027 |
released |
July 2015 |
-
Visual Studio 2015
-
Roslyn v1
C#6
- ➕ Static imports
- ➕ Exception filters
catch (ExceptionType [e]) when (expr)
- ➕ Auto-property initializers
string FirstName { get; set; } = string.Empty;
- ➕ Default values for getter-only properties
- ➕ Expression bodied members
void DisplayName() => Console.WriteLine(ToString());
- ➕ Null propagator
-
?.
and?[]
- ➕ String interpolation
Console.WriteLine($"Hello {name}");
- ➕
nameof
operator - ➕ Index initializers
var foo = new IndexableClass { [0] = 10 };
- ➕ Await in catch/finally blocks
try
{
// something that throws
}
catch
{
await Task.Delay(1000); // using await in catch block
}
4.5
released |
2012 |
-
CLR 4.0
-
Visual Studio 2012
Framework
-
Background just-in-time (JIT) compilation
C#5
- ➕ Asynchronous members aka
async
andawait
- ➕ Caller info attributes
public void TraceMessage(
string message,
[CallerMemberName] string memberName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int sourceLineNumber = 0)
{
// ...
}
4
released |
2010 |
-
CLR 4.0
-
Visual Studio 2010
Framework
- ➕ Background garbage collection
- ➕ Code Contracts
- ➕ Dynamic Language Runtime
- ➕ Windows Presentation Foundation (WPF) 4
-
Adding amongst other things DataGrid, DatePicker, and Calendar controls.
C#4
- ➕ Dynamic binding
dynamic dyn = 1;
- ➕ Named/optional arguments
ExampleMethod(3, optionalint: 4);
// where
int optionalint = 10
- ➕ Generic covariant and contravariant
-
Implicit or explicit covariant
out
and contravariantin
keyword. - ➕ Embedded interop types
-
Eases the deployment pain of creating COM interop assemblies
3
released |
2007 |
-
CLR 2.0
-
Visual Studio 2008
Framework
- ➕ Windows Presentation Foundation
- ➕ Windows Communication Foundation
- ➕ Windows Workflow Foundation
- ➕ Windows CardSpace
-
An identity selector app.
C#3
- ➕ Auto-implemented properties
public string Name { get; set; }
- ➕ Implicitly typed local variables
var
- ➕ Anonymous types
var v = new { Amount = 108, Message = "Hello" };
Notice that v has no type.
- ➕ Query expressions aka LINQ
- ➕ Lambda expressions
- ➕ Expression trees
- ➕ Extension methods
- ➕ Partial methods
partial void OnSomethingHappened(String s)
- ➕ Object and collection initializers
new Cat { Age = 10
// and
new List<int> { 0, 1, 2};
2
released |
2005 |
-
CLR 2.0
-
Visual Studio 2005
Framework
- ➕ Debugger edit and continue
- ➕ Improved scalability and performance
- ➕ ClickOnce deployment
- ➕ In ASP.NET 2.0, new controls and support for a broad array of browsers
- ➕ 64-bit support
-
For the first time.
C#02
- ➕ Generics
- ➕ Partial types
- ➕ Anonymous methods
- ➕ Iterators
- ➕ Covariance and contravariance
-
Implicit reference conversion for array types and method groups.
- ➕ Nullable value types
- ➕ Null-coalescing operator
-
??