|
2 | 2 | title: The history of C# |
3 | 3 | description: Learn how the C# language has changed over its many releases. Learn when different features were introduced in the language. |
4 | 4 | author: erikdietrich |
5 | | -ms.date: 11/22/2024 |
| 5 | +ms.date: 12/20/2024 |
6 | 6 | ms.custom: "updateeachrelease, UpdateFrequency1" |
7 | 7 | --- |
8 | 8 |
|
9 | 9 | # The history of C\# |
10 | 10 |
|
11 | | -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](https://github.com/dotnet/roslyn/blob/main/docs/Language%20Feature%20Status.md) on GitHub. |
| 11 | +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](https://github.com/dotnet/roslyn/blob/main/docs/Language%20Feature%20Status.md) on GitHub. To find when a particular feature was added to the language, consult the [C# version history](https://github.com/dotnet/csharplang/blob/main/Language-Version-History.md) file in the [`dotnet/csharplang`](https://github.com/dotnet/csharplang) repository on GitHub. |
12 | 12 |
|
13 | 13 | > [!IMPORTANT] |
14 | 14 | > 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 <xref:System.Exception>. Similarly, every `catch` is checked to ensure that the type being caught is derived from <xref:System.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](relationships-between-language-and-library.md) for background on this dependency. |
15 | 15 |
|
| 16 | +## C# version 13 |
| 17 | + |
| 18 | +*Released November 2024* |
| 19 | + |
| 20 | +C# 13 includes the following new features: |
| 21 | + |
| 22 | +- `params` collections: he `params` modifier isn't limited to array types. You can now use `params` with any recognized collection type, including `Span<T>`, and interface types. |
| 23 | +- New `lock` type and semantics: If the target of a `lock` statement is a <xref:System.Threading.Lock?displayProperty=fullName>, compiler generates code to use the <xref:System.Threading.Lock.EnterScope?displayProperty=nameWithType> method to enter an exclusive scope. The `ref struct` returned from that supports the `Dispose()` pattern to exit the exclusive scope. |
| 24 | +- New escape sequence - `\e`: You can use `\e` as a character literal escape sequence for the `ESCAPE` character, Unicode `U+001B`. |
| 25 | +- Small optimizations to overload resolution involving method groups. |
| 26 | +- Implicit indexer access in object initializers: The implicit "from the end" index operator, `^`, is now allowed in an object initializer expression. |
| 27 | +- You can use `ref` locals and `unsafe` contexts in iterators and async methods. |
| 28 | +- You can use `ref struct` types to implement interfaces. |
| 29 | +- You can allow `ref struct` types as arguments for type parameters in generics. |
| 30 | +- Partial properties and indexers are now allowed in `partial` types. |
| 31 | +- Overload resolution priority allows library authors to designate one overload as better than others. |
| 32 | + |
| 33 | +And, the `field` contextual keyword to access the compiler generated backing field in an automatically implemented property was released as a preview feature. |
| 34 | + |
16 | 35 | ## C# version 12 |
17 | 36 |
|
18 | 37 | *Released November 2023* |
|
0 commit comments