C# 的正确版本号是多少?

发布于 2024-07-08 14:20:20 字数 214 浏览 8 评论 0 原文

C# 的正确版本号是多少? 什么时候出来的? 为什么我找不到有关 C# 3.5 的任何答案?

这个问题主要是为了帮助那些使用不正确的版本号(例如C# 3.5)寻找答案的人。 希望任何因错误版本号而无法找到答案的人都能找到这个问题,然后使用正确的版本号再次搜索。

What are the correct version numbers for C#? What came out when? Why can't I find any answers about C# 3.5?

This question is primarily to aid those who are searching for an answer using an incorrect version number, e.g. C# 3.5. The hope is that anyone failing to find an answer with the wrong version number will find this question and then search again with the right version number.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

清引 2024-07-15 14:20:20

C# 语言版本历史记录:

这些是 C# 版本 在撰写本文时已知:

  • C# 1.0 与 .NET 1.0 和 VS2002 一起发布(2002 年 1 月)
  • C# 1.2(够奇怪的); 与 .NET 1.1 和 VS2003 一起发布(2003 年 4 月)。 第一个在实现了 IDisposableIEnumerator 上调用 Dispose 的版本。 其他一些小功能。
  • C# 2.0 与 .NET 2.0 和 VS2005 一起发布(2005 年 11 月)。 主要新功能:泛型、匿名方法、可空类型和迭代器块
  • C# 3.0 与 .NET 3.5 和 VS2008 一起发布(2007 年 11 月)。 lambda 表达式、扩展方法、表达式树、匿名类型、隐式类型 (var) 和查询表达式
  • 主要新功能:随 .NET 4 和 VS2010 发布的 C# 4.0(4 月) 2010)。 主要新功能:后期绑定(动态)、委托和接口通用差异、更多 COM 支持、命名参数、元组数据类型和可选参数
  • C# 5.0 随 .NET 4.5 和 VS2012 一起发布(2012 年 8 月)。 主要功能:异步编程和调用者信息属性。 重大更改:循环变量闭包
  • C# 6.0 与 .NET 4.6 和 VS2015 一起发布(2015 年 7 月)。 由 Roslyn 实现。 功能:自动实现属性的初始化程序,使用用于导入静态成员、异常过滤器、元素初始值设定项、catch 中的 awaitfinally 的指令、扩展 Add 方法集合初始值设定项。
  • C# 7.0 与 .NET 4.7 和 VS2017 一起发布(2017 年 3 月)。 主要新功能元组引用局部变量和引用返回模式匹配(包括基于模式的 switch 语句) , 内联 out 参数声明本地函数二进制文字、数字分隔符任意异步返回
  • C# 7.1 随 VS2017 v15.3 一起发布(2017 年 8 月)。 新功能:异步主元组成员名称推断默认表达式,以及与泛型匹配的模式
  • C# 7.2 随 VS2017 v15.5 一起发布(2017 年 11 月)。 新功能:私有受保护访问修饰符Span,又名内部指针,又名 stackonly 结构,以及 其他所有内容
  • C# 7.3 随 VS2017 v15.7 一起发布(2018 年 5 月)。 新功能: 枚举、委托和 <代码>非托管泛型类型约束ref 重新分配。 不安全的改进:stackalloc初始化、未固定索引固定缓冲区、自定义固定语句。 改进了重载分辨率。 初始值设定项和查询中的表达式变量。 ==!= 为元组定义。 自动属性的支持字段现在可以通过属性作为目标。
  • C# 8.0 与 .NET Core 3.0 和 VS2019 v16.3 一起发布(2019 年 9 月)。 主要新功能可空引用类型异步流指数和范围只读成员使用声明默认接口方法静态本地函数增强内插逐字字符串
  • C# 9.NET 5.0 一起发布和 VS2019 v16.8(2020 年 11 月)。 主要新功能仅初始化属性记录with-expressions、数据类、位置记录、顶级程序,< a href="https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-9#pattern-matching-enhancements" rel="noreferrer">改进的模式匹配 (简单类型模式、关系模式、逻辑模式)、改进的目标类型(目标类型 new 表达式、目标类型 ???),和协变回报。 小功能:放松 refpartial 修饰符的排序、参数 null 检查、lambda 丢弃参数、本机 int、本地函数的属性、函数指针、静态 lambda、扩展 GetEnumerator、模块初始值设定项和扩展部分。
  • C# 10 与 .NET 6.0 一起发布(2021 年 11 月)。 主要新功能:记录结构、无参数结构构造函数、内插字符串处理程序、全局 using 指令、文件范围的命名空间声明、扩展属性模式、const 内插字符串、解构中的混合赋值和声明、单个方法的异步方法构建器(通过属性)、参数的 CallerArgumentExpression 属性,增强的 #line 编译指示。
  • C# 11 与 .NET 7.0 一起发布(2022 年 11 月)。 主要新功能:文件范围类型、通用数学支持、自动默认结构、常量字符串上的模式匹配 Span、扩展名称范围、数字 IntPtr、UTF-8 字符串文字、必需成员、 ref 字段和 scoped ref、原始字符串文字、改进的方法组转换为委托、警告第 7 波、通用属性、字符串插值表达式中的换行符、列表模式
  • C# 12 与 .NET 8.0 一起发布(2023 年 11 月)。 主要新功能:主构造函数、集合表达式,内联数组,lambda表达式中的可选参数,ref readonly参数,别名任何类型,Experimental属性,拦截器

响应OP的问题:

C# 的正确版本号是多少? 什么时候出来的? 为什么我找不到有关 C# 3.5 的任何答案?

不存在 C# 3.5 这样的东西 - 这里造成混乱的原因是 C# 3.0 存在于 .NET 3.5 中。 然而,语言和框架的版本是独立的 - 就像 CLR 一样,.NET 2.0 到 3.5 的版本为 2.0,.NET 4 引入了 CLR 4.0(尽管有服务包)。 .NET 4.5 中的 CLR 有各种改进,但版本控制不清楚:在某些地方它可能被称为 CLR 4.5 (此 MSDN 页面 过去常常以这种方式引用它),但是Environment.Version 属性仍报告 4.0.xxx。

截至 2017 年 5 月 3 日,C# 语言团队在其 GitHub 存储库上创建了 C# 版本和功能的历史记录:C# 语言版本中添加的功能。 还有一个跟踪即将推出和最近实现的语言功能的页面

C# language version history:

These are the versions of C# known about at the time of this writing:

  • C# 1.0 released with .NET 1.0 and VS2002 (January 2002)
  • C# 1.2 (bizarrely enough); released with .NET 1.1 and VS2003 (April 2003). First version to call Dispose on IEnumerators which implemented IDisposable. A few other small features.
  • C# 2.0 released with .NET 2.0 and VS2005 (November 2005). Major new features: generics, anonymous methods, nullable types, and iterator blocks
  • C# 3.0 released with .NET 3.5 and VS2008 (November 2007). Major new features: lambda expressions, extension methods, expression trees, anonymous types, implicit typing (var), and query expressions
  • C# 4.0 released with .NET 4 and VS2010 (April 2010). Major new features: late binding (dynamic), delegate and interface generic variance, more COM support, named arguments, tuple data type and optional parameters
  • C# 5.0 released with .NET 4.5 and VS2012 (August 2012). Major features: async programming, and caller info attributes. Breaking change: loop variable closure.
  • C# 6.0 released with .NET 4.6 and VS2015 (July 2015). Implemented by Roslyn. Features: initializers for automatically implemented properties, using directives to import static members, exception filters, element initializers, await in catch and finally, extension Add methods in collection initializers.
  • C# 7.0 released with .NET 4.7 and VS2017 (March 2017). Major new features: tuples, ref locals and ref return, pattern matching (including pattern-based switch statements), inline out parameter declarations, local functions, binary literals, digit separators, and arbitrary async returns.
  • C# 7.1 released with VS2017 v15.3 (August 2017). New features: async main, tuple member name inference, default expression, and pattern matching with generics.
  • C# 7.2 released with VS2017 v15.5 (November 2017). New features: private protected access modifier, Span<T>, aka interior pointer, aka stackonly struct, and everything else.
  • C# 7.3 released with VS2017 v15.7 (May 2018). New features: enum, delegate and unmanaged generic type constraints. ref reassignment. Unsafe improvements: stackalloc initialization, unpinned indexed fixed buffers, custom fixed statements. Improved overloading resolution. Expression variables in initializers and queries. == and != defined for tuples. Auto-properties' backing fields can now be targeted by attributes.
  • C# 8.0 released with .NET Core 3.0 and VS2019 v16.3 (September 2019). Major new features: nullable reference-types, asynchronous streams, indices and ranges, readonly members, using declarations, default interface methods, static local functions, and enhancement of interpolated verbatim strings.
  • C# 9 released with .NET 5.0 and VS2019 v16.8 (November 2020). Major new features: init-only properties, records, with-expressions, data classes, positional records, top-level programs, improved pattern matching (simple type patterns, relational patterns, logical patterns), improved target typing (target-type new expressions, target typed ?? and ?), and covariant returns. Minor features: relax ordering of ref and partial modifiers, parameter null checking, lambda discard parameters, native ints, attributes on local functions, function pointers, static lambdas, extension GetEnumerator, module initializers, and extending partial.
  • C# 10 released with .NET 6.0 (November 2021). Major new features: record structs, struct parameterless constructors, interpolated string handlers, global using directives, file-scoped namespace declarations, extended property patterns, const interpolated strings, mixed assignment and declaration in deconstruction, async method builders (via attributes) for individual methods, the CallerArgumentExpression attribute for parameters, enhanced #line pragmas.
  • C# 11 released with .NET 7.0 (November 2022). Major new features: file-scoped types, generic math support, auto-default structs, pattern match Span<char> on a constant string, extended nameof scope, numeric IntPtr, UTF-8 string literals, required members, ref fields and scoped ref, raw string literals, improved method group conversion to delegate, warning wave 7, generic attributes, newlines in string interpolation expressions, list patterns
  • C# 12 released with .NET 8.0 (November 2023). Major new features: primary constructors, collection expressions, inline arrays, optional parameters in lambda expressions, ref readonly parameters, alias any type, Experimental attribute, interceptors

In response to the OP's question:

What are the correct version numbers for C#? What came out when? Why can't I find any answers about C# 3.5?

There is no such thing as C# 3.5 - the cause of confusion here is that the C# 3.0 is present in .NET 3.5. The language and framework are versioned independently, however - as is the CLR, which is at version 2.0 for .NET 2.0 through 3.5, .NET 4 introducing CLR 4.0, service packs notwithstanding. The CLR in .NET 4.5 has various improvements, but the versioning is unclear: in some places it may be referred to as CLR 4.5 (this MSDN page used to refer to it that way, for example), but the Environment.Version property still reports 4.0.xxx.

As of May 3, 2017, the C# Language Team created a history of C# versions and features on their GitHub repository: Features Added in C# Language Versions. There is also a page that tracks upcoming and recently implemented language features.

姜生凉生 2024-07-15 14:20:20

这与此处的大多数答案相同,但为了方便而以表格形式呈现,并且它具有 Visual Studio.NET 版本以确保完整性。

C# 版本 VS 版本 .NET 版本 CLR 版本 发布日期
1.0 2002 1.0 1.0 Feb 2002
1.2 2003 1.1 1.1 Apr 2003
2.0 2005 2.0 2.0 Nov 2005
3.0 2.0 Nov 2006
3.0 2008 3.5 2.0 Nov 2007
4.0 2010 4.0 4 2010年4月
日5.0 2012年 4.5 4 8月 日2012年
2013年 4.5.1 4 2013年10月
4.5.2 2014年5月
4日 6.0 2015年 4.6 4 2015年7月
日 4.6.1 4 2015年11月
日4.6.2 4 2016年8月
日 7.0 2017 年3月
4.7 4日 2017年5月
7.1 2017年(v15.3) 2017年8月
4.7.1 4 2017年10月
日 2017年7.2 (v15.5) 2017年12月
4.7.2 4 2018年4月
日 2017年7.3 (v15.7) May 2018
8.0 2019 4.8 4 Apr 2019
4.8.1 4 Aug 2022

版本自 .NET Core

C# 版本 VS 版本 .NET 版本 发布日期 支持结束
2015 Update 3 .NET Core 1.0 Jun 2016 Jun 2019
.NET Core 1.1 2016年11 月 2019年
6月7.0 2017 年3月 2017年
7.1 2017 (v15.3) .NET Core 2.0 2017年8月 2018年10月
7.3 2017 (v15.7) .NET Core 2.1 2018年5月 2021年8月
.NET Core 2.2 2018年 12月 2019年12
月 8.0 2019 2019年
2019年(v16.3) .NET Core 3.0 2019年9 4月
月 2020年3月2019年(v16.4) .NET Core 3.1 2019年 12月 2022年12月
9 (†) 2019 (v16.8) .NET 5 Nov 2020 May 2022
10 2022 .NET 6 Nov 2021 Nov 2024
11 2022 (17.4) .NET 7 Nov 2022 May 2024
12 2022 (17.8) .NET 8 Nov 2023 Nov 2026

* - .NET 5.0 不是较新版本.NET 框架,但 .NET Core 3。从 .NET 5.0 开始,没有更新版本的 .NET 完整框架。

** - 没有单独的 CLR (CoreCLR) .NET Core 的版本。 无论 .NET Core 版本是什么,都是 CoreCLR 版本。 所以就不提了。


注意: .NET 几乎独立于 VS 和编译器版本,每个版本之间没有相关性。 上面的列表并不意味着某些版本的 .NET 与某些 C# 或 VS 版本相关。 这只是按照其发布的时间顺序(VS/C# 和 .NET)编译的。 有些版本碰巧在一起,因此它们位于同一行。
请参阅“.NET Framework 版本和依赖项”和“.NET 发布节奏”了解更多信息。

major.minor 版本控制方案变成了 major 从 C# 9 开始

This is the same as most answers here, but tabularized for ease, and it has Visual Studio and .NET versions for completeness.

C# version VS version .NET version CLR version Release date
1.0 2002 1.0 1.0 Feb 2002
1.2 2003 1.1 1.1 Apr 2003
2.0 2005 2.0 2.0 Nov 2005
3.0 2.0 Nov 2006
3.0 2008 3.5 2.0 Nov 2007
4.0 2010 4.0 4 Apr 2010
5.0 2012 4.5 4 Aug 2012
2013 4.5.1 4 Oct 2013
4.5.2 4 May 2014
6.0 2015 4.6 4 Jul 2015
4.6.1 4 Nov 2015
4.6.2 4 Aug 2016
7.0 2017 Mar 2017
4.7 4 May 2017
7.1 2017 (v15.3) Aug 2017
4.7.1 4 Oct 2017
7.2 2017 (v15.5) Dec 2017
4.7.2 4 Apr 2018
7.3 2017 (v15.7) May 2018
8.0 2019 4.8 4 Apr 2019
4.8.1 4 Aug 2022

Versions since .NET Core

C# version VS version .NET version Release date End of Support
2015 Update 3 .NET Core 1.0 Jun 2016 Jun 2019
.NET Core 1.1 Nov 2016 Jun 2019
7.0 2017 Mar 2017
7.1 2017 (v15.3) .NET Core 2.0 Aug 2017 Oct 2018
7.3 2017 (v15.7) .NET Core 2.1 May 2018 Aug 2021
.NET Core 2.2 Dec 2018 Dec 2019
8.0 2019 Apr 2019
2019 (v16.3) .NET Core 3.0 Sep 2019 Mar 2020
2019 (v16.4) .NET Core 3.1 Dec 2019 Dec 2022
9 (†) 2019 (v16.8) .NET 5 Nov 2020 May 2022
10 2022 .NET 6 Nov 2021 Nov 2024
11 2022 (17.4) .NET 7 Nov 2022 May 2024
12 2022 (17.8) .NET 8 Nov 2023 Nov 2026

* - .NET 5.0 is not a newer version of .NET framework but .NET Core 3. Starting from .NET 5.0, there are no newer versions of .NET full framework.

** - There are no separate CLR (CoreCLR) versions for .NET Core. Whatever is the .NET Core version is the CoreCLR version. So not mentioning it.


Note: .NET is pretty much independent of VS and compiler versions, there is no correlation between versions of each. The above lists don't imply certain version of .NET are tied to certain C# or VS versions. This is just compiled in their chronological order of their releases (VS/C# and .NET). Some releases happen to be together, hence they sit in the same row.
Refer to ".NET Framework versions and dependencies" and ".NET release cadence" for more.

† The major.minor versioning scheme became just major starting with C# 9

旧梦荧光笔 2024-07-15 14:20:20

处理 C# 版本号时最大的问题是它与 .NET Framework 的版本无关,这似乎是由于 Visual Studio 和 .NET Framework 之间的同步版本所致。

C#的版本实际上是与编译器绑定的,而不是与框架绑定的。 例如,在 Visual Studio 2008 中,您可以编写 C# 3.0 并面向 .NET Framework 2.0、3.0 和 3.5。 C# 3.0 命名法以与 ANSI C89、C90 和C99 描述了 C 的代码语法和功能。

看看 Mono,你就会请参阅 Mono 2.0(主要是 ECMA 规范中 .NET Framework 2.0 版本的实现)支持 C# 3.0 语法和功能。

The biggest problem when dealing with C#'s version numbers is the fact that it is not tied to a version of the .NET Framework, which it appears to be due to the synchronized releases between Visual Studio and the .NET Framework.

The version of C# is actually bound to the compiler, not the framework. For instance, in Visual Studio 2008 you can write C# 3.0 and target .NET Framework 2.0, 3.0 and 3.5. The C# 3.0 nomenclature describes the version of the code syntax and supported features in the same way that ANSI C89, C90, and C99 describe the code syntax and features for C.

Take a look at Mono, and you will see that Mono 2.0 (mostly implemented version 2.0 of the .NET Framework from the ECMA specifications) supports the C# 3.0 syntax and features.

巨坚强 2024-07-15 14:20:20
黯淡〆 2024-07-15 14:20:20
版本 语言规范 Microsoft 编译器
C# 1.0/1.2 2001 年 12 月?/2003? 2002 年 1 月?
C# 2.0 2005 年 9 月 2005 年 11 月
C# 3.0 2006 年 5 月 2006 年 11 月
C# 4.0 2009 年 3 月(草案) 2010 年 4 月
C# 5.0 与 .NET 4.5 一起发布2012 年 8 月
C# 6.0 随 .NET 4.6 发布 2015
C# 7.0 随 .NET 4.7 发布 2017
C# 8.0 随 .NET 4.8 发布 2019
Version Language specification Microsoft compiler
C# 1.0/1.2 December 2001?/2003? January 2002?
C# 2.0 September 2005 November 2005?
C# 3.0 May 2006 November 2006?
C# 4.0 March 2009 (draft) April 2010?
C# 5.0 Released with .NET 4.5 in August 2012
C# 6.0 Released with .NET 4.6 2015
C# 7.0 Released with .NET 4.7 2017
C# 8.0 Released with .NET 4.8 2019
寂寞美少年 2024-07-15 14:20:20

我在此表中总结了大部分版本。 唯一缺少的应该是 ASP.NET Core 版本。 我还添加了不同版本的 ASP.NET MVC。

请注意,ASP.NET 5 已更名为 ASP.NET Core 1.0,ASP.NET MVC 6 已更名为 ASP.NET Core MVC 1.0.0。 我相信此更改发生在 2016 年 1 月左右的某个时间。

我已在表中包含 ASP.NET 5 RC1 的发布日期,但尚未包含 ASP.NET core 1.0 和其他核心版本,因为我找不到确切的发布日期。 您可以在此处阅读有关 ASP.NET Core 发布日期的更多信息:ASP.NET Core 1.0 (ASP.NET 5 / vNext) 计划何时发布?

版本

I've summarised most of the versions in this table. The only ones missing should be ASP.NET Core versions. I've also added different versions of ASP.NET MVC.

Note that ASP.NET 5 has been rebranded as ASP.NET Core 1.0 and ASP.NET MVC 6 has been rebranded as ASP.NET Core MVC 1.0.0. I believe this change occurred sometime around Jan 2016.

I have included the release date of ASP.NET 5 RC1 in the table, but I've yet to include ASP.NET core 1.0 and other core versions, because I couldn't find the exact release dates. You can read more about the release dates regarding ASP.NET Core here: When is ASP.NET Core 1.0 (ASP.NET 5 / vNext) scheduled for release?

Version

笔芯 2024-07-15 14:20:20

您可以在此处查看最新的 C# 版本
C# 版本

You can check the latest C# versions here
C# Versions

淡淡的优雅 2024-07-15 14:20:20

比较 MSDN 文章 “C# 2.0 中的新增功能”语言和编译器” 和“什么Visual C# 2005 中的新增功能”,可以根据编译器的版本编号推断出“C# Major_version.minor_version”是创造的。

C# 1.2 对应于 .NET 1.1 和 VS 2003,也命名为如 Visual C# .NET 2003

但更进一步,微软停止增加次要版本号(点后)或将其设置为非零,0。 但值得注意的是,对应于 .NET 3.5 的 C# 在 msdn.microsoft.com 中被命名为 "Visual C# 2008 Service Pack 1"

有两种并行命名方式:按主要 .NET/编译器版本编号和 Visual Studio 编号。

C# 2.0 是 < 的同义词a href="http://msdn.microsoft.com/en-US/library/t27ahy37%28v=vs.80%29.aspx" rel="noreferrer">Visual C# 2005

C# 3.0 对应(或,更正确地说,可以定位)到:

Comparing the MSDN articles "What's New in the C# 2.0 Language and Compiler" and "What's New in Visual C# 2005", it is possible to deduce that "C# major_version.minor_version" is coined according to the compiler's version numbering.

There is C# 1.2 corresponding to .NET 1.1 and VS 2003 and also named as Visual C# .NET 2003.

But further on Microsoft stopped to increment the minor version (after the dot) numbers or to have them other than zero, 0. Though it should be noted that C# corresponding to .NET 3.5 is named in msdn.microsoft.com as "Visual C# 2008 Service Pack 1".

There are two parallel namings: By major .NET/compiler version numbering and by Visual Studio numbering.

C# 2.0 is a synonym for Visual C# 2005

C# 3.0 corresponds (or, more correctly, can target) to:

离去的眼神 2024-07-15 14:20:20

C# 1.0 - Visual Studio .NET 2002

  • 结构
  • 体 接口
  • 事件
  • 属性
  • 委托
  • 表达式
  • 语句
  • 属性
  • 文字

C# 1.2 - Visual Studio .NET 2003

  • 在 foreach 中处理
  • foreach 字符串特化
  • C# 2 - Visual Studio 2005
  • 泛型
  • 部分类型
  • 匿名方法
  • 迭代器
  • 可空类型
  • Getter/setter单独的可访问性
  • 方法组转换(委托)
  • 静态类
  • 委托推理

C# 3 - Visual Studio 2008

  • 隐式类型局部变量
  • 对象和集合初始值设定项
  • 自动实现的属性
  • 匿名类型
  • 扩展方法
  • 查询表达式
  • Lambda 表达式
  • 表达式树
  • 部分方法

C# 4 - Visual Studio 2010

  • 动态绑定
  • 命名参数和可选参数
  • 泛型委托和接口的协变和逆变
  • 嵌入式互操作类型(“NoPIA”)

C# 5 - Visual Studio 2012

  • 异步方法
  • 调用者信息属性

C# 6 - Visual Studio 2015

  • 在线规范草案
  • 编译器即服务(Roslyn)
  • 将静态类型成员导入命名空间
  • 异常过滤器
  • 在 catch/finally 块中等待
  • 自动属性初始
  • 值设定项 仅 getter 属性的默认值
  • 表达式主体成员
  • 空传播器(空条件运算符、简洁的空值检查)
  • 字符串插值
  • nameof 运算符
  • 字典初始值

设定项C# 7.0 - Visual Studio 2017

  • 输出变量
  • 模式匹配
  • 元组
  • 解构
  • 丢弃
  • 本地函数
  • 二进制文字 数字
  • 分隔
  • 符 引用返回和局部
  • 变量 通用异步返回类型
  • 更多表达式主体成员
  • 抛出表达式

C# 7.1 - Visual Studio 2017 版本 15.3

  • 异步 main
  • 默认表达式
  • 引用程序集
  • 推断元组元素名称
  • 与泛型的模式匹配

C# 7.2 - Visual Studio 2017 版本 15.5

  • 跨度和类引用类型
  • 在参数和只读引用中
  • Ref 条件式
  • 非尾随命名参数
  • 私有受保护的可访问性
  • 基本说明符后的数字分隔符

C# 7.3 - Visual Studio 2017 版本 15.7

  • 系统.Enum、System.Delegate 和非托管约束。
  • Ref 本地重新分配:Ref 本地和 ref 参数现在可以使用 ref 赋值运算符 (= ref) 重新分配。
  • Stackalloc 初始化器:现在可以初始化堆栈分配的数组,例如 Span x = stackalloc[] { 1, 2, 3 };。
  • 索引可移动固定缓冲区:无需先固定即可对固定缓冲区进行索引。
  • 自定义固定语句:实现合适的 GetPinnableReference 的类型可以在固定语句中使用。
  • 改进的重载候选:可以尽早排除一些重载决议候选,从而减少歧义。
  • 初始值设定项和查询中的表达式变量:字段初始值设定项、构造函数初始值设定项和 LINQ 查询中允许使用诸如 out var 和模式变量之类的表达式变量。
  • 元组比较:元组现在可以使用 == 和 != 进行比较。
  • 支持字段上的属性:允许自动实现的属性上的 [field: …] 属性定位其支持字段。

C# 8.0 - .NET Core 3.0 和 Visual Studio 2019 版本 16.3

  • 可空引用类型:使用 API 中的 ?、notnull 约束和注释属性表达引用类型的可空性意图,编译器将使用这些属性来尝试检测可能被取消引用或传递的空值到不合适的 API。
  • 默认接口成员:接口现在可以具有默认实现的成员,以及除状态之外的静态/私有/受保护/内部成员(即无字段)。
  • 递归模式:位置和属性模式允许更深入地测试对象,而开关表达式允许测试多个模式并以紧凑的方式生成相应的结果。
  • 异步流:await foreach 和await using 允许异步枚举和处置IAsyncEnumerable 集合和IAsyncDisposable 资源,并且异步迭代器方法允许方便地实现此类异步流。
  • 增强的 using:添加了带有隐式作用域的 using 声明,并且 using 语句和声明允许使用模式处理 ref 结构。
  • 范围和索引:i..j 语法允许构造 System.Range 实例,^k 语法允许构造 System.Index 实例,这些可用于索引/切片集合。
  • 空合并赋值:??= 允许在值为空时有条件地赋值。
  • 静态局部函数:用 static 修饰的局部函数无法捕获 this 或局部变量,并且局部函数参数现在会隐藏父作用域中的局部变量。
  • 非托管泛型结构:仅具有非托管字段的泛型结构类型现在被视为非托管(即它们满足非托管约束)。
  • 只读成员:现在可以将各个成员标记为只读,以指示并强制他们不会修改实例状态。
  • 嵌套上下文中的 Stackalloc:现在在更多表达式上下文中允许使用 stackalloc 表达式。
  • 替代内插逐字字符串:@$"..." 字符串被识别为内插逐字字符串,就像 $@"..." 一样。
  • 属性访问器已过时:属性访问器现在可以单独标记为已过时。
  • 允许 t 在无约束类型参数上为 null

[来源]: https://github.com/dotnet/csharplang/blob/master/Language-Version-History.md

C# 1.0 - Visual Studio .NET 2002

  • Classes
  • Structs
  • Interfaces
  • Events
  • Properties
  • Delegates
  • Expressions
  • Statements
  • Attributes
  • Literals

C# 1.2 - Visual Studio .NET 2003

  • Dispose in foreach
  • foreach over string specialization
  • C# 2 - Visual Studio 2005
  • Generics
  • Partial types
  • Anonymous methods
  • Iterators
  • Nullable types
  • Getter/setter separate accessibility
  • Method group conversions (delegates)
  • Static classes
  • Delegate inference

C# 3 - Visual Studio 2008

  • Implicitly typed local variables
  • Object and collection initializers
  • Auto-Implemented properties
  • Anonymous types
  • Extension methods
  • Query expressions
  • Lambda expression
  • Expression trees
  • Partial methods

C# 4 - Visual Studio 2010

  • Dynamic binding
  • Named and optional arguments
  • Co- and Contra-variance for generic delegates and interfaces
  • Embedded interop types ("NoPIA")

C# 5 - Visual Studio 2012

  • Asynchronous methods
  • Caller info attributes

C# 6 - Visual Studio 2015

  • Draft Specification online
  • Compiler-as-a-service (Roslyn)
  • Import of static type members into namespace
  • Exception filters
  • Await in catch/finally blocks
  • Auto property initializers
  • Default values for getter-only properties
  • Expression-bodied members
  • Null propagator (null-conditional operator, succinct null checking)
  • String interpolation
  • nameof operator
  • Dictionary initializer

C# 7.0 - Visual Studio 2017

  • Out variables
  • Pattern matching
  • Tuples
  • Deconstruction
  • Discards
  • Local Functions
  • Binary Literals
  • Digit Separators
  • Ref returns and locals
  • Generalized async return types
  • More expression-bodied members
  • Throw expressions

C# 7.1 - Visual Studio 2017 version 15.3

  • Async main
  • Default expressions
  • Reference assemblies
  • Inferred tuple element names
  • Pattern-matching with generics

C# 7.2 - Visual Studio 2017 version 15.5

  • Span and ref-like types
  • In parameters and readonly references
  • Ref conditional
  • Non-trailing named arguments
  • Private protected accessibility
  • Digit separator after base specifier

C# 7.3 - Visual Studio 2017 version 15.7

  • System.Enum, System.Delegate and unmanaged constraints.
  • Ref local re-assignment: Ref locals and ref parameters can now be reassigned with the ref assignment operator (= ref).
  • Stackalloc initializers: Stack-allocated arrays can now be initialized, e.g. Span x = stackalloc[] { 1, 2, 3 };.
  • Indexing movable fixed buffers: Fixed buffers can be indexed into without first being pinned.
  • Custom fixed statement: Types that implement a suitable GetPinnableReference can be used in a fixed statement.
  • Improved overload candidates: Some overload resolution candidates can be ruled out early, thus reducing ambiguities.
  • Expression variables in initializers and queries: Expression variables like out var and pattern variables are allowed in field initializers, constructor initializers and LINQ queries.
  • Tuple comparison: Tuples can now be compared with == and !=.
  • Attributes on backing fields: Allows [field: …] attributes on an auto-implemented property to target its backing field.

C# 8.0 - .NET Core 3.0 and Visual Studio 2019 version 16.3

  • Nullable reference types: express nullability intent on reference types with ?, notnull constraint and annotations attributes in APIs, the compiler will use those to try and detect possible null values being dereferenced or passed to unsuitable APIs.
  • Default interface members: interfaces can now have members with default implementations, as well as static/private/protected/internal members except for state (ie. no fields).
  • Recursive patterns: positional and property patterns allow testing deeper into an object, and switch expressions allow for testing multiple patterns and producing corresponding results in a compact fashion.
  • Async streams: await foreach and await using allow for asynchronous enumeration and disposal of IAsyncEnumerable collections and IAsyncDisposable resources, and async-iterator methods allow convenient implementation of such asynchronous streams.
  • Enhanced using: a using declaration is added with an implicit scope and using statements and declarations allow disposal of ref structs using a pattern.
  • Ranges and indexes: the i..j syntax allows constructing System.Range instances, the ^k syntax allows constructing System.Index instances, and those can be used to index/slice collections.
  • Null-coalescing assignment: ??= allows conditionally assigning when the value is null.
  • Static local functions: local functions modified with static cannot capture this or local variables, and local function parameters now shadow locals in parent scopes.
  • Unmanaged generic structs: generic struct types that only have unmanaged fields are now considered unmanaged (ie. they satisfy the unmanaged constraint).
  • Readonly members: individual members can now be marked as readonly to indicate and enforce that they do not modify instance state.
  • Stackalloc in nested contexts: stackalloc expressions are now allowed in more expression contexts.
  • Alternative interpolated verbatim strings: @$"..." strings are recognized as interpolated verbatim strings just like $@"...".
  • Obsolete on property accessors: property accessors can now be individually marked as obsolete.
  • Permit t is null on unconstrained type parameter

[Source]: https://github.com/dotnet/csharplang/blob/master/Language-Version-History.md

贪了杯 2024-07-15 14:20:20
Version     .NET Framework     Visual Studio     Important Features

C# 1.0 .NET Framework 1.0/1.1 Visual Studio .NET 2002

  • 基本功能

C# 2.0 .NET Framework 2.0 Visual Studio 2005 泛型

  • 部分类型
  • 匿名方法
  • 迭代器
  • 空类型
  • 私有设置器(属性)
  • 方法组转换(委托)
  • 协变和逆变
  • 静态类

C# 3.0 .NET Framework 3.0\3.5 Visual Studio 2008

  • 隐式类型局部变量
  • 对象和集合初始值设定项
  • 自动实现的属性
  • 匿名类型
  • 扩展方法
  • 查询表达式
  • Lambda 表达式
  • 表达式树
  • 部分方法

C# 4.0 .NET Framework 4.0 Visual Studio 2010

  • 动态绑定(后期绑定)
  • 命名参数和可选参数
  • 通用协变和逆变
  • 嵌入式互操作类型

C# 5.0 .NET Framework 4.5 Visual Studio 2012/2013

  • 异步功能
  • 调用者信息

C# 6.0 .NET Framework 4.6 Visual Studio 2013/2015

  • 表达式实体方法
  • 自动属性初始值设定项
  • nameof Expression
  • 主构造函数
  • Await in catch 块
  • 异常过滤器
  • 字符串插值

C# 7.0 .NET Core 2.0 Visual Studio 2017

  • out 变量
  • 元组
  • 丢弃
  • 模式匹配
  • 本地函数
  • 通用异步返回类型
  • 数字文字语法改进

C# 8.0 .NET Core 3.0 Visual Studio 2019

  • 只读成员
  • 默认接口方法
  • 模式匹配增强功能:
    • 切换表达式
    • 属性模式
    • 元组模式
    • 位置模式
  • 使用声明
  • 静态局部函数
  • 赋值
  • 可一次性引用结构 可空引用类型
  • 异步流
  • 异步
  • 一次性索引和范围
  • 空合并
  • 非托管构造类型
  • 嵌套表达式中的 Stackalloc 内
  • 插逐字字符串的增强
Version     .NET Framework     Visual Studio     Important Features

C# 1.0 .NET Framework 1.0/1.1 Visual Studio .NET 2002

  • Basic features

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 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 Expression
  • Primary constructor
  • Await in catch block
  • Exception Filter
  • String Interpolation

C# 7.0 .NET Core 2.0 Visual Studio 2017

  • out variables
  • Tuples
  • Discards
  • Pattern Matching
  • Local functions
  • Generalized async return types
  • Numeric literal syntax improvements

C# 8.0 .NET Core 3.0 Visual Studio 2019

  • Readonly members
  • Default interface methods
  • Pattern matching enhancements:
    • Switch expressions
    • Property patterns
    • Tuple patterns
    • Positional patterns
  • Using declarations
  • Static local functions
  • Disposable ref structs
  • Nullable reference types
  • Asynchronous streams
  • Asynchronous disposable
  • Indices and ranges
  • Null-coalescing assignment
  • Unmanaged constructed types
  • Stackalloc in nested expressions
  • Enhancement of interpolated verbatim strings
静待花开 2024-07-15 14:20:20

C# 8.0 是 C# 的最新版本。 仅 .NET Core 3.x 及更高版本支持它。 许多最新功能需要 .NET Core 3.x 中引入的库和运行时功能。

下表列出了目标框架及其版本及其默认 C# 版本。

C# 语言具有 Target 框架的版本

来源 - C# 语言版本控制

C# 8.0 is the latest version of C#. It is supported only on .NET Core 3.x and newer versions. Many of the newest features require library and runtime features introduced in .NET Core 3.x.

The following table lists the target framework with version and their default C# version.

C# language version with Target framework

Source - C# language versioning

锦上情书 2024-07-15 14:20:20

我一直在寻找 .NET、C#、CLR 和 Visual Studio 版本的简明历史以及关键语言功能。

由于我找不到任何包含我需要的所有信息的最新表格,因此我将 Microsoft 文档中的详细信息合并到我试图保留一个包含我正在寻找的内容的简洁表格中。

它可以在这里找到: https://mantinband.github.io/dotnet-shmotnet/

我可能存在一些错误或缺少信息,因此请随时在此处提出问题或做出贡献:https:// github.com/mantinband/dotnet-shmotnet

先睹为快:

在此处输入图像描述

I was looking for a concise history of the .NET, C#, CLR, and Visual Studio versions alongside the key language features.

Since I couldn't find any up-to-date table that contains all the information I needed in one place - I merged details from the Microsoft docs into what I tried to keep a concise table that contains what I was looking for.

It’s available here: https://mantinband.github.io/dotnet-shmotnet/

I probably have some mistakes or missing information so please feel free to open an issue or contribute over here: https://github.com/mantinband/dotnet-shmotnet

Sneak peek:

Enter image description here

时光与爱终年不遇 2024-07-15 14:20:20

您可以在 Microsoft 的参考

You can find a list of all the C# language versions on Microsoft's reference.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文