[toc]html
Version | Date | .NET Framework | CLR | Visual Studio |
---|---|---|---|---|
C# 1.0 | 2002.01 | .NET Framework 1.0 | 1.0 | VS 2002 |
C# 1.1<br />C# 1.2 | 2003.10 | .NET Framework 1.1 | 1.1 | VS 2003 |
C# 2.0 | 2005.11 | .NET Framework 2.0 | 2.0 | VS 2005 |
C# 3.0 | 2007.11 | .NET Framework 2.0<br />.NET Framework 3.0<br />.NET Framework 3.5 | 2.0 | VS 2008<br />VS 2010 |
C# 4.0 | 2010.04 | .NET Framework 4 | 4.0 | VS 2010 |
C# 5.0 | 2012.08 | .NET Framework 4.5<br />.NET Framework 4.5.1 | 4.0 | VS 2012<br />VS 2013 |
C# 6.0 | 2015.07 | .NET Framework 4.6 | 4.0 | VS 2015 |
C# 7.0 | 2017.03 | .NET Framework 4.6.2 | 4.0 | VS 2017 |
C# 7.1 | 2017.08 | .NET Framework 4.7 | 4.0 | VS 2017 v15.3 |
C# 7.2 | 2017.11 | .NET Framework 4.7.1 | 4.0 | VS 2017 v15.5 |
C# 7.3 | 2018.05 | .NET Framework 4.7.2 | 4.0 | VS 2017 v15.7 |
C# 8.0 | 2019.10 | .NET Framework 4.8 | 4.0 | VS 2019 v16.3 |
Dispose in foreach:當 IEnumerator 實現 IDisposable 時,foreach 循環中生成的代碼會在 IEnumerator 上調用 Dispose。git
foreach over string specialization:foreach上的字符串特化。github
in
修飾符和針對方法返回的 ref readonly
修飾符,能夠在編寫安全高效的代碼中詳細瞭解全部這些更改。System.Enum
, System.Delegate
and unmanaged
constraints.= ref
).Span x = stackalloc[] { 1, 2, 3 };
.fixed
statement: Types that implement a suitable GetPinnableReference
can be used in a fixed
statement.out var
and pattern variables are allowed in field initializers, constructor initializers and LINQ queries.==
and !=
.[field: …]
attributes on an auto-implemented property to target its backing field.?
, notnull
constraint and annotations attributes in APIs, the compiler will use those to try and detect possible null
values being dereferenced or passed to unsuitable APIs.await foreach
and await using
allow for asynchronous enumeration and disposal of IAsyncEnumerable
collections and IAsyncDisposable
resources, and async-iterator methods allow convenient implementation of such asynchronous streams.using
declaration is added with an implicit scope and using
statements and declarations allow disposal of ref
structs using a pattern.i..j
syntax allows constructing System.Range
instances, the ^k
syntax allows constructing System.Index
instances, and those can be used to index/slice collections.??=
allows conditionally assigning when the value is null.static
cannot capture this
or local variables, and local function parameters now shadow locals in parent scopes.unmanaged
constraint).readonly
to indicate and enforce that they do not modify instance state.stackalloc
expressions are now allowed in more expression contexts.@$"..."
strings are recognized as interpolated verbatim strings just like $@"..."
.t is null
on unconstrained type parameternative(原生)
,該特性容許聲明一個32位或64位的數據類型,這取決於操做系統的平臺類型。