原文地址:https://blog.csdn.net/t163361/article/details/107266702
Unity 2020.2 C#8
Unity 2018.3 C#7.3
Unity 2018.2 C#7.2
Unity 2017.1 C#6
Unity 5.5 C#4.0
C#8.0新特性
- Nullable reference types:可空引用类型
- Default interface members::默认接口成员
- Recursive patterns:递归模式
- Async streams:异步流
- Enhanced using:增强using
- Ranges and indexes:范围和索引
- Null-coalescing assignment: Null合并分配
- Static local functions:静态本地函数
- Unmanaged generic structs:非托管泛型structs
- Readonly members:只读成员
- Stackalloc in nested contexts:嵌套上下文中的Stackalloc
- Obsolete on property accessors:属性访问器已经过时
- Permit t is null on unconstrained type parameter:不受限制的类型参数的许可
C#7.3新特性
- System.Enum, System.Delegate and unmanaged constraints:泛型约束,枚举、委托和非托管
- Ref local re-assignment:现在可以使用ref分配运算符(= ref)重新分配 Ref locals和ref参数。
- Stackalloc initializers:现在可以初始化堆栈分配的数组
- Indexing movable fixed buffers:索引可移动固定缓冲区
- Custom fixed statement:自定义fixed语句
- Improved overload candidates:改进重载候选项
- Expression variables in initializers and queries:初始化和查询中的表达式变量
- Tuple comparison:元组比较
- Attributes on backing fields:后备字段属性
C#7.2新特性
- Span and ref-like types ref-like类型的编译安全规则
- In parameters and readonly references:值类型的引用语法
- Ref conditional:条件ref
- Non-trailing named arguments:不在尾部的指定名字参数
- Private protected accessibility:访问修饰符
- Digit separator after base specifier:前缀数字(非十进制)分割
C#7.1新特性
- Async main:异步Main方法
- Default expressions:默认表达式
- Reference assemblies:参考程序集
- Inferred tuple element names:推断元组元素名称
- Pattern-matching with generics:泛型的模式匹配
C#7.0新特性
- Out variables:out变量直接声明,例如可以out in parameter
- Pattern matching:模式匹配,根据对象类型或者其它属性实现方法派发
- Tuple 元组
- Deconstruction:元组解析
- Discards:舍弃
- Local Functions:本地函数
- Binary Literals:二进制文字
- Digit Separators:数字分隔符
- Ref returns and locals:Ref返回和临时变量
- Generalized async return types:异步返回类型的广泛支持
- More expression-bodied members:更多表达式化的成员体
- Throw expressions:抛出表达式
C#6.0新特性
- Draft Specification online
- Compiler-as-a-service (Roslyn)
- Import of static type members into namespace:支持仅导入类中的静态成员
- Exception filters:异常过滤器
- Await in catch/finally blocks:支持在catch/finally语句块使用await语句
- Auto property initializers:自动属性初始化
- Default values for getter-only properties:设置只读属性的默认值
- Expression-bodied members:支持以表达式为主体的成员方法和只读属性
- Null propagator (null-conditional operator, succinct null checking):Null条件操作符
- String interpolation:字符串插值,产生特定格式字符串的新方法
- nameof operator:nameof操作符,返回方法、属性、变量的名称
- Dictionary initializer:字典初始化
C#5.0新特性
- Asynchronous methods 异步方法
- Caller info attributes:调用时访问调用者的信息
- foreach loop was changed to generates a new loop variable rather than closing over the same variable every time
C#4新特性
- Dynamic binding:动态绑定
- Named and optional arguments:命名参数和可选参数
- Generic co- and contravariance:泛型的协变和逆变
- Embedded interop types (“NoPIA”):开启嵌入类型信息,增加引用COM组件程序的中立性
C#3新特性
- Implicitly typed local variables
- Object and collection initializers
- Auto-Implemented properties
- Anonymous types
- Extension methods
- Query expressions, a.k.a LINQ (Language Integrated Query)
- Lambda expression
- Expression trees
- Partial methods
- Lock statement
C#2新特性
- Generics
- Partial types
- Anonymous methods
- Iterators, a.k.a yield statement
- Nullable types
- Getter/setter separate accessibility
- Method group conversions (delegates)
- Static classes
- Delegate inference
- Type and namespace aliases
- Covariance and contravariance
C#1.2新特性
- Dispose in foreach
- foreach over string specialization
C#1特性
- Classes
- Structs
- Enums
- Interfaces
- Events
- Operator overloading
- User-defined conversion operators
- Properties
- Indexers
- Output parameters (out and ref)
- params arrays
- Delegates
- Expressions
- using statement
- goto statement
- Preprocessor directives
- Unsafe code and pointers
- Attributes
- Literals
- Verbatim identifier
- Unsigned integer types
参考资料:
C#9
C#更新列表
C#documentation
C#参考
[Unity脚本运行时更新]C#7.2新特性
[Unity脚本运行时更新]C#7.1新特性
[Unity脚本运行时更新]C#7新特性
[Unity脚本运行时更新]C#6新特性
[Unity脚本运行时更新]C#5新特性
[Unity脚本运行时更新]C#4新特性