Edit

Share via


The history of C#

This article provides a history of each major release of the C# language. The C# team is continuing to innovate and add new features. Detailed language feature status, including features considered for upcoming releases can be found on the dotnet/roslyn repository on GitHub. To find when a particular feature was added to the language, consult the C# version history file in the dotnet/csharplang repository on GitHub.

Important

The C# language relies on types and methods in what the C# specification defines as a standard library for some of the features. The .NET platform delivers those types and methods in a number of packages. One example is exception processing. Every throw statement or expression is checked to ensure the object being thrown is derived from Exception. Similarly, every catch is checked to ensure that the type being caught is derived from Exception. Each version may add new requirements. To use the latest language features in older environments, you may need to install specific libraries. These dependencies are documented in the page for each specific version. You can learn more about the relationships between language and library for background on this dependency.

C# version 13

Released November 2024

C# 13 includes the following new features:

  • params collections: the params modifier isn't limited to array types. You can now use params with any recognized collection type, including Span<T>, and interface types.
  • New lock type and semantics: If the target of a lock statement is a System.Threading.Lock, compiler generates code to use the Lock.EnterScope() method to enter an exclusive scope. The ref struct returned from that supports the Dispose() pattern to exit the exclusive scope.
  • New escape sequence - \e: You can use \e as a character literal escape sequence for the ESCAPE character, Unicode U+001B.
  • Small optimizations to overload resolution involving method groups.
  • Implicit indexer access in object initializers: The implicit "from the end" index operator, ^, is now allowed in an object initializer expression.
  • You can use ref locals and unsafe contexts in iterators and async methods.
  • You can use ref struct types to implement interfaces.
  • You can allow ref struct types as arguments for type parameters in generics.
  • Partial properties and indexers are now allowed in partial types.
  • Overload resolution priority allows library authors to designate one overload as better than others.

And, the field contextual keyword to access the compiler generated backing field in an automatically implemented property was released as a preview feature.

C# version 12

Released November 2023

The following features were added in C# 12:

And, Interceptors - was released as a Preview feature.

Overall, C# 12 provides new features that make you more productive writing C# code. Syntax you already knew is available in more places. Other syntax enables consistency for related concepts.

C# version 11

Released November 2022

The following features were added in C# 11:

C# 11 introduces generic math and several features that support that goal. You can write numeric algorithms once for all number types. There's more features to make working with struct types easier, like required members and auto-default structs. Working with strings gets easier with Raw string literals, newline in string interpolations, and UTF-8 string literals. Features like file local types enable source generators to be simpler. Finally, list patterns add more support for pattern matching.

C# version 10

Released November 2021

C# 10 adds the following features and enhancements to the C# language:

More features were available in preview mode. In order to use these features, you must set <LangVersion> to Preview in your project:

C# 10 continues work on themes of removing ceremony, separating data from algorithms, and improved performance for the .NET Runtime.

Many of the features mean you type less code to express the same concepts. Record structs synthesize many of the same methods that record classes do. Structs and anonymous types support with expressions. Global using directives and file scoped namespace declarations mean you express dependencies and namespace organization more clearly. Lambda improvements make it easier to declare lambda expressions where they're used. New property patterns and deconstruction improvements create more concise code.

The new interpolated string handlers and AsyncMethodBuilder behavior can improve performance. These language features were applied in the .NET Runtime to achieve performance improvements in .NET 6.

C# 10 also marks more of a shift to the yearly cadence for .NET releases. Because not every feature can be completed in a yearly timeframe, you can try a couple of "preview" features in C# 10. Both generic attributes and static abstract members in interfaces can be used, but these preview features might change before their final release.

C# version 9

Released November 2020

C# 9 was released with .NET 5. It's the default language version for any assembly that targets the .NET 5 release. It contains the following new and enhanced features: