首页 / 教程列表 / C#程序设计基础(入门篇) / C#版本历史和特性

C#版本历史和特性

2157 更新于: 2023-01-17 读完约需 10 分钟

C#在2002年首次与.NET Framework 1.0一起发布,下表列出了每个版本C#中引入的重要特性:

C#版本号 .NET Framework版本 Visual Studio版本 新特性
C# 1.0 .NET Framework 1.0/1.1 Visual Studio .NET 2002 C#的基础特性
C# 2.0 .NET Framework 2.0 Visual Studio 2005 泛型(Generics)
部分类(Partial types)
匿名方法(Anonymous methods)
迭代器(Iterators)
可空类型(Nullable types)
属性私有设置器(Private setters) (properties)
方法组转换(委托)Method group conversions (delegates)
协变和逆变(Covariance and Contra-variance)
静态类(Static classes)
C# 3.0 .NET Framework 3.0\3.5 Visual Studio 2008 隐式类型局部变量(Implicitly typed local variables)
对象和集合初始化器(Object and collection initializers)
自动实现的属性(Auto-Implemented properties)
匿名类型(Anonymous types)
扩展方法(Extension methods)
查询表达式(Query expressions)
Lambda表达式(Lambda expressions)
表达式树(Expression trees)
部分方法(Partial Methods)
C# 4.0 .NET Framework 4.0 Visual Studio 2010 动态绑定(Dynamic binding(late binding))
命名和可选参数(Named and optional arguments)
泛型协变和逆变(Generic co- and contravariance)
嵌入式互操作类型(Embedded interop types)
C# 5.0 .NET Framework 4.5 Visual Studio 2012/2013 异步方法(Async features)
调用者信息(Caller information)
C# 6.0 .NET Framework 4.6 Visual Studio 2013/2015 表达式方法(Expression Bodied Methods)
自动属性初始化器(Auto-property initializer)
nameof表达式(nameof Expression)
在Catch和Finally中使用Await(Await in catch block)
异常过滤器(Exception Filter)
字符串插值(String Interpolation)
C# 7.0 .NET Core 2.0 Visual Studio 2017 out变量(out variables)
元组和解构(Tuples and deconstruction)
模式匹配(Pattern Matching)
局部函数(Local functions)
扩展异步返回类型(Generalized async return types)
局部引用和引用返回(Ref locals and returns)
Throw表达式(Throw expressions)
二进制文字和数字分隔符(Binary Literals and Digit Separators)
弃元(Discards)
C# 7.1 .NET Framework 4.7 Visual Studio 2017 version 15.3 异步Main方法(async Main method)
默认迭代表达式(default literal expressions)
推断元组元素名(Inferred tuple element names)
泛型类型参数上的模式匹配(Pattern matching on generic type parameters)
C# 7.2 .NET Framework 4.7.1 Visual Studio 2017 version 15.5 支持使用引用语义处理值类型的语法改进的组合(Techniques for writing safe efficient code)
非尾随命名参数(Non-trailing named arguments)
数字文本语法改进(Leading underscores in numeric literals)
私有/保护访问修饰符(private protected access modifier)
ref条件表达式(Conditional ref expressions)
C# 7.3 .NET Framework 4.7.2 Visual Studio 2017 version 15.7 You can access fixed fields without pinning
You can reassign ref local variables.
You can use initializers on stackalloc arrays.
You can use fixed statements with any type that supports a pattern.
You can use additional generic constraints.
C# 8.0 .NET Core 3.0 Visual Studio 2019 只读成员(Readonly members)
默认接口方法(Default interface methods)
Using声明(Using declarations)
静态局部函数(Static local functions)
可释放的ref结构(Disposable ref structs)
可穷引用类型(Nullable reference types)
模式匹配增强功能(Pattern matching enhancements)
Switch表达式(Switch expressions)
属性模式(Property patterns)
元组模式(Tuple patterns)
位置模式(Positional patterns)
异步流(Asynchronous streams)
索引和范围(Indices and ranges)
Null 合并赋值(Null-coalescing assignment)
非托管构造类型(Unmanaged constructed types)
嵌套表达式中的 Stackalloc(Stackalloc in nested expressions)
内插逐字字符串的增强功能(Enhancement of interpolated verbatim strings)
C# 9.0 .NET 5.0 Visual Studio 2019 Records Init-only
properties
Top-level
statements
Init accessors and readonly fields
With-expressions
Value-based equality
C# 10.0 .NET 6.0 Visual Studio 2022 Record structs
Global using directives
File-scoped namespace declaration
Extended Proptery Patterns
Null Parameter Checking
Constant interpolated strings

版权声明:本作品系原创,版权归码友网所有,如未经许可,禁止任何形式转载,违者必究。

发表评论

登录用户才能发表评论, 请 登 录 或者 注册