C# 1 | Classes Structs Interfaces Events Properties Delegates Expressions Statements Attributes |
C# 2 | Generics Nullable value types Method group conversions Anonymous methods Delegate covariance and contravariance Iterators ( yield return )Partial types Static classes Separate getter/setter access on properties Namespace alias qualifier :: syntaxThe global **namespace aliasExtern aliases Fixed-size buffers InternalsVisibleToAttribute support |
C# 3 | Partial methods Automatically implemented properties Implicitly typed local variables ( var )Implicitly typed arrays ( new[] )Object initializers Collection initializers Anonymous types Lambda expressions (delegates) Lambda expressions (expression trees) Extension methods Query expressions |
C# 4 | Dynamic typing Optional parameters Named arguments Linked primary interop assemblies Special rules for optional parameters in COM Access to named indexers (COM only) Generic variance for interfaces and delegates Implementation change to lock statements Implementation changes to field-like events Field-like event access within the declaring class |
C# 5 | async / await Changes to foreach iteration variable captureCaller information attributes |
C# 6 | Read-only automatically implemented properties Initializers for automatically implemented properties Remove requirement to call this() in constructors for structs containing automatically implemented propertiesExpression-bodied members Interpolated string literals The nameof operatorThe using static directiveObject initializers using indexers Collection initializers using extension Add methods The null conditional ?. operatorException filters Removed restrictions on awaiting in try/catch , try/finally , and try/catch statements |
C# 7.0 | Tuples Deconstruction via Deconstruct methodsInitial patterns: constant patterns, type patterns, var **patternsUse of patterns with the is **operatorUse of patterns in switch statements, including guard clauses ( when )Ref locals Ref return Binary integer literals Underscore separators in numeric literals Returning custom task types from async methods More kinds of expression-bodied members |
C# 7.1 | The default **literalImprovements to type patterns matching against generic values Async entry points ( async Task Main )Inferred tuple element names |
C# 7.2 | Allow the conditional ?: operator to work with refref readonly locals and return typesin parametersRead-only structs Extension methods with ref/in parameters Ref-like structs stackalloc support for Span<T> Nontrailing named arguments The private protected access modifierUnderscore separators in numeric literals directly after the 0x or 0b base specifier |
C# 7.3 | Access to fixed-sized buffers via fields without fixed statements*==* and != operators for tuplesUse of pattern and out variables in field, property, and constructor initializersReassignment of ref locals Initializers in stackalloc statementsPattern-based fixed statements using GetPinnableReference Generic type constraints now permitted on Enum and Delegate New generic type constraint of unmanaged Placement of attributes of fields backing automatically implemented properties |
C# 8.0 | Readonly members Default interface methods Pattern matching enhancements: Switch expressions, Property patterns, Tuple patterns Positional patterns Using declarations Static local functions Disposable ref structs Nullable reference types Asynchronous streams Indices and ranges Null-coalescing assignment Unmanaged constructed types stackalloc in nested expressionsEnhancement of interpolated verbatim string |
C# 9.0 (preview) |
Init-only properties - Init accessors and readonly fields Records ( data class )- With-expressions - Value-based equality - Data members - Positional records - With-expressions and inheritance - Value-based equality and inheritance Top-level programs (omitting Main method)Improved pattern matching - Simple type patterns - Relational patterns - Logical patterns - Target-typed new expressions- Target typed ?? and ?: Covariant returns |
참고
- C# in Depth 4 ed
- The history of C# https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history
- Welcome to C# 9.0 https://devblogs.microsoft.com/dotnet/welcome-to-c-9-0/
- dotnet/csharplang Milestone: 9.0 candidate https://github.com/dotnet/csharplang/milestone/15