ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

C#(017):C# 语言历史版本特性(C# 1.0到C# 8.0汇总)

2022-05-15 08:02:45  阅读:201  来源: 互联网

标签:8.0 1.0 C# Visual Studio https csharp NET


一、简介

C#作为微软2000年以后.NET平台开发的当家语言,发展至今具有17年的历史,语言本身具有丰富的特性,微软对其更新支持也十分支持。微软将C#提交给标准组织ECMA,C#
5.0目前是ECMA发布的最新规范,C# 6.0还是草案阶段,C# 7.1是微软当前提供的最新规范。

这里仅仅列个提纲,由于C# 5.0是具有ECMA标准规范的版本,所以选择C# 5.0作为主要版本学习,并专题学习C# 6.0,7.0版本新特性。

C#语言版本发展历史:

<https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-new/csharp-version-
history>

C#语言路线图及开发中的特性参见:
https://github.com/dotnet/roslyn/blob/master/docs/Language Feature Status.md

语言版本 发布时间 .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 Visual Studio 2017 v15.3
C# 8.0 待发布 .NET Framework 4.7.1 Visual Studio 2019

二、版本历史

1、C# 1.0 特性(Visual Studio.NET)

  • Classes:面向对象特性,支持类类型
  • Structs:结构
  • Interfaces:接口
  • Events:事件
  • Properties:属性,类的成员,提供访问字段的灵活方法
  • Delegates:委托,一种引用类型,表示对具有特定参数列表和返回类型的方法的引用
  • Expressions,Statements,Operators:表达式、语句、操作符
  • Attributes:特性,为程序代码添加元数据或声明性信息,运行时,通过反射可以访问特性信息
  • Literals:字面值(或理解为常量值),区别常量,常量是和变量相对的

2、C# 2特性 (VS 2005)

  • Generics:泛型
  • Partial types:分部类型,可以将类、结构、接口等类型定义拆分到多个文件中
  • Anonymous methods:匿名方法
  • Iterators:迭代器
  • Nullable types:可以为Null的类型,该类可以是其它值或者null
  • Getter/setter separate accessibility:属性访问控制
  • Method group conversions (delegates):方法组转换,可以将声明委托代表一组方法,隐式调用
  • Co- and Contra-variance for delegates and interfaces:委托、接口的协变和逆变
  • Static classes:静态类
  • Delegate inference:委托推断,允许将方法名直接赋给委托变量

3、C# 3特性 (VS 2008)

详解:https://www.cnblogs.com/springsnow/p/9428687.html

  • Implicitly typed local variables:
  • Object and collection initializers:对象和集合初始化器
  • Auto-Implemented properties:自动属性,自动生成属性方法,声明更简洁
  • Anonymous types:匿名类型
  • Extension methods:扩展方法
  • Query expressions:查询表达式
  • Lambda expression:Lambda表达式
  • Expression trees:表达式树,以树形数据结构表示代码,是一种新数据类型
  • Partial methods:部分方法

4、C# 4特性 (VS 2010)

详解:https://www.cnblogs.com/springsnow/p/11652915.html

  • Dynamic binding:动态绑定
  • Named and optional arguments:命名参数和可选参数
  • Generic co- and contravariance:泛型的协变和逆变
  • Embedded interop types (“NoPIA”):开启嵌入类型信息,增加引用COM组件程序的中立性

5、C# 5特性 (VS 2012)

详解:https://www.cnblogs.com/springsnow/p/9400851.html

  • Asynchronous methods:异步方法
  • Caller info attributes:调用方信息特性,调用时访问调用者的信息

6、C# 6特征 (VS 2015)

C# 6 中的新增功能: https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-new/csharp-6

  • 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:字典初始化

7、C# 7 特征 (Visual Studio 2017)

详解:https://www.cnblogs.com/springsnow/p/9531103.html

https://www.cnblogs.com/springsnow/p/11606167.html

C# 7.0 中的新增功能: https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-
new/csharp-7

  • 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可以在表达式中使用

8、C# 7.1 特征 (Visual Studio 2017 version 15.3)

C# 7.1 中的新增功能: https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-
new/csharp-7-1

  • Async main:在main方法用async方式
  • Default expressions:引入新的字面值default
  • Reference assemblies:
  • Inferred tuple element names:
  • Pattern-matching with generics:

9、C# 7.2 特征(Visual Studio 2017 version 15.5)

C# 7.2 中的新增功能: https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-
new/csharp-7-2

10、C# 7.3 特征(Visual Studio 2017 version 15.7)

C# 7.3 中的新增功能: https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-
new/csharp-7-3

11、C# 8.0 特征 (Visual Studio 2019 第一版16.0.1起)

详解:https://www.cnblogs.com/springsnow/p/11046251.html

C# 8.0 中的新增功能: https://docs.microsoft.com/zh-cn/dotnet/csharp/whats-
new/csharp-8

  • 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

标签:8.0,1.0,C#,Visual,Studio,https,csharp,NET
来源: https://www.cnblogs.com/springsnow/p/16272226.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有