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.
-
8 (November 2023) LTS until November 2026
-
-
+Primary constructors:
class BankAccount(string accountID, string owner)
-
+Collection expressions:
string[] names = ["Julia", "Anna", "Thomas"];
andstring[] 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 (November 2022)
-
-
+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
-
+File-local types:
file
access modifier is scoped to the source
-
-
-
6 (November 2021) LTS until November 2024
-
.NET 6 unifies the SDK, base libraries, and runtime across mobile, desktop, IoT, and cloud apps.
-
-
+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
-
+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
-
-
-
5 (November 2020) (skips "Core" and is now the main implementation of .NET going forward)
-
-
+Pattern matching enhancements:
-
relational patterns:
<
,>
,⇐
, or>=
-
logical patterns:
and
,or
,not
-
-
+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 (December 2019) LTS until December 2022
-
Core 3.0 (September 2019) (.NET Standard 2.1 ⇒ 37,118 of the 37,118 APIs)
-
+WinForms, WPF on Windows
-
-
+
readonly
members -
+Default interface methods: methods in interface can have an implementation now
-
+Pattern matching enhancements
-
+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" };
-
+link:https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/nullable-reference-types]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
-
-
-
4.8 (August 2019) the final framework (still stuck at .NET Standard 2.0 ⇒ 32,638 of the 37,118 APIs)
-
C# ⇐ 7.3
-
-
Core 2.2 (December 2018)
-
Core 2.1 (May 2018) LTS until August 2021
-
Core 2.0 (August 2017) (.NET Standard 2.0 ⇒ 32,638 of the 37,118 APIs)
-
-
+
async
Main method -
+default literal expressions
-
+Inferred tuple element names
-
+Pattern matching on generic type parameters
-
-
-
4.7 (June 2017) (.NET Standard 2.0 ⇒ 32,638 of the 37,118 APIs)
-
Visual Studio 2017
-
C#7 (March 2017)
-
+Out variables:
GetEmployeeDetails(out string EmployeeName);
-
+Tuples and deconstruction:
var t = ("post office", 3.6);
andvar (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;
andref 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;
andvar bigNumber = 123_456_789;
-
+Throw expressions:
string first = args.Length >= 1 ? args[0] : throw new ArgumentException("Please supply at least one argument.");
-
-
-
Core 1 (June 2016) (.NET Standard 1.6 ⇒ 13,501 of the 37,118 APIs)
-
Cross-platform: Runs on Windows, macOS and Linux.
-
-
4.6 (July 2015) (.NET Standard 2.0 ⇒ 32,638 of the 37,118 APIs) LTS until January 2027
-
Visual Studio 2015
-
Roslyn v1
-
C#6 (July 2015)
-
+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
-
-
F# 4
-
VB 14
-
-
4.5 (2012)
-
CLR 4.0
-
Visual Studio 2012
-
Framework
-
Background just-in-time (JIT) compilation
-
-
-
Asynchronous members aka
async
andawait
-
Caller info attributes
-
-
-
4 (2010)
-
CLR 4.0
-
Visual Studio 2010
-
Framework
-
+Background garbage collection
-
+Code Contracts
-
+Dynamic Language Runtime
-
+Windows Presentation Foundation (WPF) 4
-
-
-
+Dynamic binding:
dynamic dyn = 1;
-
+Named/optional arguments:
ExampleMethod(3, optionalint: 4);
whereint 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
-
-
-
-
CLR 2.0
-
Framework
-
+WCF and WF integration
-
+Peer-to-Peer networking
-
+Add-ins for extensibility
-
-
-
3 (2007)
-
CLR 2.0
-
Visual Studio 2008
-
Framework
-
+Windows Presentation Foundation
-
+Windows Communication Foundation
-
+Windows Workflow Foundation
-
+Windows CardSpace
-
-
-
+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
andnew List<int> { 0, 1, 2};
-
-
-
2 (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
-
-
-
+Generics
-
+Partial types
-
+Anonymous methods
-
+Iterators
-
+Covariance and contravariance: implicit reference conversion for array types and method groups.
-
+Nullable value types
-
+Null-coalescing operator
??
-
-
-
1 (2002): Initial Release
-
CLR 1.0
-