C#版本和.NET版本以及VS版本的對應關系


C# 語言歷史版本特性

C# 版本號 .NET Framework版本號 Visual Studio版本 發布日期 特性
C# 1.0 .NET Framework 1.0 Visual Studio .NET 2002 2002.1 委托 事件等
C# 1.1 .NET Framework 1.1 Visual Studio .NET 2003 2003.4 APM(異步編程模型)
C# 2.0 .NET Framework 2.0 Visual Studio 2005(開始命名為Visual Studio) 2005.11 泛型,
匿名方法,
迭代器,
可空類型
C# 3.0 .NET Framework 3.0 Visual Studio 2008 2007.11 隱式類型
.NET Framework 3.5 2007.11 對象集合初始化,
自動實現屬性,
匿名類型,擴展方法,
查詢表達式,Lambda表達式,
表達式樹,分部類和方法,
Linq
C# 4.0 .NET Framework 4.0 Visual Studio 2010 2010.4 動態綁定,
命名和可選參數,
泛型的協變和逆變,
互操作性
C# 5.0 .NET Framework 4.5 Visual Studio 2012 2012.8 異步和等待(async和await);
調用方信息(CallerInformation)
.NET Framework4.5.1 Visual Studio 2013 2013.11
C#6.0 .NET Framework4.6 Visual Studio 2015 2015.7 字符串內插
靜態導入
異常篩選器
自動屬性初始化表達式
Expression bodied 成員
Null 傳播器
nameof 運算符
.NET Core 1.0 2016-06-27
C#7.0 .NET Framework 4.6.2 Visual Studio 2017 2017.3 元組,C#7 中的新增功能
C# 7.1 .NET Framework 4.7 Visual Studio 2017 version 15.3 2017.8
.Net Core2.0 2016.8.4 .NET Core 2.0 的新增功能
C# 7.2 .NET Framework 4.7.1 2017-10-17
C# 7.3 .NET Framework 4.7.2 2018-04-30
.NET Core 2.1 2018-05-30 .NET Core 2.1 的新增功能
.NET Core 2.2 2018-12-04 .NET Core 2.2 的新增功能
C# 8.0 .NET Framework 4.8 2019-04-18 C# 8.0 中的新增功能
.NET Core 3.0 2019-09-23 .NET Core 3.0 的新增功能
.NET Core 3.1 2019-12-03 .NET Core 3.1 的新增功能
C# 9.0 .NET 5 2020-09-04 C# 9.0 中的新增功能
.NET 5 2020-10-13 What's new in .NET 5

C#1.0特性

  • Events:事件
  • Delegates:委托,一種引用類型,表示對具有特定參數列表和返回類型的方法的引用
    Classes:面向對象特性,支持類類型
    Structs:結構
    Interfaces:接口
    Properties:屬性,類的成員,提供訪問字段的靈活方法
    Expressions,Statements,Operators:表達式、語句、操作符
    Attributes:特性,為程序代碼添加元數據或聲明性信息,運行時,通過反射可以訪問特性信息
    Literals:字面值(或理解為常量值),區別常量,常量是和變量相對的

C#2.0特性

  • Generics:泛型
  • Anonymous methods:匿名方法
  • Iterators:迭代器
  • Nullable types:可以為Null的類型,該類可以是其它值或者null
    Partial types:分部類型,可以將類、結構、接口等類型定義拆分到多個文件中
    Getter/setter separate accessibility:屬性訪問控制
    Method group conversions (delegates):方法組轉換,可以將聲明委托代表一組方法,隱式調用
    Co- and Contra-variance for delegates and interfaces:委托、接口的協變和逆變
    Static classes:靜態類
    Delegate inference:委托推斷,允許將方法名直接賦給委托變量

C#3.0特性

Implicitly typed local variables:
Object and collection initializers:對象和集合初始化器
Auto-Implemented properties:自動屬性,自動生成屬性方法,聲明更簡潔
Anonymous types:匿名類型
Extension methods:擴展方法
Query expressions:查詢表達式
Lambda expression:Lambda表達式
Expression trees:表達式樹,以樹形數據結構表示代碼,是一種新數據類型
Partial methods:部分方法

C#4.0特性

Dynamic binding:動態綁定
Named and optional arguments:命名參數和可選參數
Generic co- and contravariance:泛型的協變和逆變
Embedded interop types (“NoPIA”):開啟嵌入類型信息,增加引用COM組件程序的中立性

C#5.0特性

Asynchronous methods:異步方法
Caller info attributes:調用方信息特性,調用時訪問調用者的信息

C#6.0

  • String interpolation:字符串插值,產生特定格式字符串的新方法,即使用$代替String.Format
    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條件操作符
    nameof operator:nameof操作符,返回方法、屬性、變量的名稱
    Dictionary initializer:字典初始化

C#7.0

Out variables:out變量直接聲明,例如可以out in parameter
Pattern matching:模式匹配,根據對象類型或者其它屬性實現方法派發
Tuples:元組
Deconstruction:元組解析
Discards:沒有命名的變量,只是占位,后面代碼不需要使用其值
Local Functions:局部函數
Binary Literals:二進制字面量
Digit Separators:數字分隔符
Ref returns and locals:引用返回值和局部變量
Generalized async return types:async中使用泛型返回類型
More expression-bodied members:允許構造器、解析器、屬性可以使用表達式作為body
Throw expressions:Throw可以在表達式中使用

C# 7.1 特征

Async main:在main方法用async方式
Default expressions:引入新的字面值default
Reference assemblies:
Inferred tuple element names:
Pattern-matching with generics:
**C# 8.0 特征 (Visual Studio 2017 version 15.7)
Default Interface Methods 缺省接口實現
Nullable reference type NullableReferenceTypes 非空和可控的數據類型
Recursive patterns 遞歸模式
Async streams 異步數據流
Caller expression attribute 調用方法表達式屬性
Target-typed new
Generic attributes 通用屬性
Ranges
Default in deconstruction
Relax ordering of ref and partial modifiers


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM