C# 和 .NET
语言版本 | 发布时间 | .NET Framework 要求 | Visual Studio 版本 |
---|---|---|---|
C# 1.0 | 2002.1 | .NET Framework 1.0 | Visual Studio .NET 2002 |
C# 1.1/1.2 | 2003.4 | .NET Framework 1.1 | Visual Studio .NET 2003 |
C# 2.0 | 2005.11 | .NET Framework 2.0 | Visual Studio 2005 |
C# 3.0 | 2007.11 | .NET Framework 2.0/3.0/3.5 | Visual Studio 2008 |
C# 4.0 | 2010.4 | .NET Framework 4.0 | Visual Studio 2010 |
C# 5.0 | 2012.8 | .NET Framework 4.5 | Visual Studio 2012/2013 |
C# 6.0 | 2015.7 | .NET Framework 4.6 | Visual Studio 2015 |
C# 7.0 | 2017.3 | .NET Framework 4.6.2 | Visual Studio 2017 |
C# 7.1 | 2017.6 | .NET Framework 4.7 | Visual Studio 2017 v15.3 预览版 |
C# 7.2 | 2017.11 | .NET Framework 4.7.1 | Visual Studio 2017 v15.5 |
C# 7.3 | 2018.5 | .NET Framework 4.7.2 | Visual Studion 2017 v15.7 |
C# 8.0 | 2019.04.18 | .NET Framework 4.8/.NET Core 3/3.1 | Visual Studion 2019 |
C# 9 | 2020.09.04 | .NET 5 | Visual Studion 2019 |
C# 10.0 | 2021.11.09 | .NET 6 | Visual Studion 2022 |
C# 11 | 2022.11.8 | .NET 7 | Visual Studion 2022 |
C# 版本及其语言特性
C# 1.0 [2002 年 01 月]
类、结构、接口、事件、属性、委托,运算符和表达式、语句、特性
C# 2.0 [2005 年 11 月]
泛型、Partial 类型、匿名方法、迭代器、可空类型、私有 setters、方法组转化(delegates)、协变和逆变、静态类
C# 3.0 [2007 年 11 月]
隐式类型的局部变量(var)、对象与集合初始化器、自动实现属性(get;set;)、Partial 方法、匿名类、扩展方法、LINQ、Lambda 表达式、表达式树
https://msdn.microsoft.com/en-us/library/bb308966.aspx
C# 4.0 [2010 年 04 月]
动态绑定(dynamic)、命名参数和可选参数、泛型协变和逆变、嵌入式互操作类型
https://msdn.microsoft.com/en-us/magazine/ff796223.aspx
C# 5.0 [2012 年 08 月]
异步特性(async & await)、调用者信息
https://learn.microsoft.com/zh-cn/archive/blogs/mvpawardprogram/an-introduction-to-new-features-in-c-5-0
C# 6.0 [2015 年 07 月]
表达式为主体的成员方法和只读属性、属性初始化赋值、nameof 表达式、Await in catch block、异常过滤器(when)、字符串插值
https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-6
C# 7.0 [2017 年 03 月]
out variables、Tuples、Discards、Pattern Matching、局部方法、Generalized async return types
https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-7
C# 8.0 [2019 年 04 月]
Readonly members、默认接口方法、Using declarations、静态局部方法、Disposable ref structs、可空引用类型
https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-8
C# 9.0 [2020 年 09 月]
Records、Init-only properties、Top-level statements、Init accessors and readonly fields、With 表达式、Value-based equality、Primary constructor
https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9
C# 10.0 [2021 年 11 月]
Record structs、Global using directives、File-scoped namespace declaration、Extended Proptery Patterns、Null Parameter Checking、Constant interpolated strings
https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-10
C# 11.0 [2022 年 11 月]
原生字符串字面量、Generic math support、泛型 attributes、UTF-8 字符串字面量、Newlines in string interpolation expressions、List patterns、file 类修饰符、Required members、Auto-default structs、Pattern match Span
https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-11
综合
https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history