C# 的正确版本号是多少?
C# 的正确版本号是多少? 什么时候出来的? 为什么我找不到有关 C# 3.5 的任何答案?
这个问题主要是为了帮助那些使用不正确的版本号(例如C# 3.5)寻找答案的人。 希望任何因错误版本号而无法找到答案的人都能找到这个问题,然后使用正确的版本号再次搜索。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
C# 语言版本历史记录:
这些是 C# 版本 在撰写本文时已知:
IDisposable
的IEnumerator
上调用Dispose
的版本。 其他一些小功能。var
) 和查询表达式动态
)、委托和接口通用差异、更多 COM 支持、命名参数、元组数据类型和可选参数catch
中的await
和finally
的指令、扩展Add
方法集合初始值设定项。out
参数声明,本地函数,二进制文字、数字分隔符和任意异步返回。ref
重新分配。 不安全的改进:stackalloc初始化、未固定索引固定缓冲区、自定义固定语句。 改进了重载分辨率。 初始值设定项和查询中的表达式变量。==
和!=
为元组定义。 自动属性的支持字段现在可以通过属性作为目标。new
表达式、目标类型??
和?
),和协变回报。 小功能:放松ref
和partial
修饰符的排序、参数 null 检查、lambda 丢弃参数、本机int
、本地函数的属性、函数指针、静态 lambda、扩展 GetEnumerator、模块初始值设定项和扩展部分。using
指令、文件范围的命名空间声明、扩展属性模式、const 内插字符串、解构中的混合赋值和声明、单个方法的异步方法构建器(通过属性)、参数的CallerArgumentExpression
属性,增强的#line
编译指示。Span
、扩展名称范围、数字IntPtr
、UTF-8 字符串文字、必需成员、ref
字段和scoped ref
、原始字符串文字、改进的方法组转换为委托、警告第 7 波、通用属性、字符串插值表达式中的换行符、列表模式响应OP的问题:
不存在 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:
Dispose
onIEnumerator
s which implementedIDisposable
. A few other small features.var
), and query expressionsdynamic
), delegate and interface generic variance, more COM support, named arguments, tuple data type and optional parametersawait
incatch
andfinally
, extensionAdd
methods in collection initializers.out
parameter declarations, local functions, binary literals, digit separators, and arbitrary async returns.unmanaged
generic type constraints.ref
reassignment. Unsafe improvements:stackalloc
initialization, unpinned indexedfixed
buffers, customfixed
statements. Improved overloading resolution. Expression variables in initializers and queries.==
and!=
defined for tuples. Auto-properties' backing fields can now be targeted by attributes.new
expressions, target typed??
and?
), and covariant returns. Minor features: relax ordering ofref
andpartial
modifiers, parameter null checking, lambda discard parameters, nativeint
s, attributes on local functions, function pointers, static lambdas, extensionGetEnumerator
, module initializers, and extending partial.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, theCallerArgumentExpression
attribute for parameters, enhanced#line
pragmas.Span<char>
on a constant string, extended nameof scope, numericIntPtr
, UTF-8 string literals, required members,ref
fields andscoped ref
, raw string literals, improved method group conversion to delegate, warning wave 7, generic attributes, newlines in string interpolation expressions, list patternsref readonly
parameters, alias any type,Experimental
attribute, interceptorsIn response to the OP's question:
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.
这与此处的大多数答案相同,但为了方便而以表格形式呈现,并且它具有 Visual Studio 和 .NET 版本以确保完整性。
版本自 .NET Core
* - .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.
Versions since .NET Core
* - .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 justmajor
starting with C# 9处理 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.
C# 1.0 与 Visual Studio .NET< /p>
< strong>C# 2.0 与 Visual Studio 2005
< strong>C# 3.0 与 Visual Studio 2008
< strong>C# 4.0 与 Visual Studio 2010
< strong>C# 5.0 与 Visual Studio 2012
< strong>C# 6.0 与 Visual Studio 2015
< strong>C# 7.0 与 Visual Studio 2017
< strong>C# 8.0 与 Visual Studio 2019
< strong>C# 9.0 与 Visual Studio 2019
C# 1.0 with Visual Studio .NET
C# 2.0 with Visual Studio 2005
C# 3.0 with Visual Studio 2008
C# 4.0 with Visual Studio 2010
C# 5.0 with Visual Studio 2012
C# 6.0 with Visual Studio 2015
C# 7.0 with Visual Studio 2017
C# 8.0 with Visual Studio 2019
C# 9.0 with Visual Studio 2019
我在此表中总结了大部分版本。 唯一缺少的应该是 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?
您可以在此处查看最新的 C# 版本
You can check the latest C# versions here
比较 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:
C# 1.0 - Visual Studio .NET 2002
C# 1.2 - Visual Studio .NET 2003
C# 3 - Visual Studio 2008
C# 4 - Visual Studio 2010
C# 5 - Visual Studio 2012
C# 6 - Visual Studio 2015
设定项C# 7.0 - Visual Studio 2017
C# 7.1 - Visual Studio 2017 版本 15.3
C# 7.2 - Visual Studio 2017 版本 15.5
C# 7.3 - Visual Studio 2017 版本 15.7
C# 8.0 - .NET Core 3.0 和 Visual Studio 2019 版本 16.3
[来源]: https://github.com/dotnet/csharplang/blob/master/Language-Version-History.md
C# 1.0 - Visual Studio .NET 2002
C# 1.2 - Visual Studio .NET 2003
C# 3 - Visual Studio 2008
C# 4 - Visual Studio 2010
C# 5 - Visual Studio 2012
C# 6 - Visual Studio 2015
C# 7.0 - Visual Studio 2017
C# 7.1 - Visual Studio 2017 version 15.3
C# 7.2 - Visual Studio 2017 version 15.5
C# 7.3 - Visual Studio 2017 version 15.7
C# 8.0 - .NET Core 3.0 and Visual Studio 2019 version 16.3
[Source]: https://github.com/dotnet/csharplang/blob/master/Language-Version-History.md
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
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
C# 7.0 .NET Core 2.0 Visual Studio 2017
C# 8.0 .NET Core 3.0 Visual Studio 2019
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
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
C# 7.0 .NET Core 2.0 Visual Studio 2017
C# 8.0 .NET Core 3.0 Visual Studio 2019
C# 8.0 是 C# 的最新版本。 仅 .NET Core 3.x 及更高版本支持它。 许多最新功能需要 .NET Core 3.x 中引入的库和运行时功能。
下表列出了目标框架及其版本及其默认 C# 版本。
来源 - 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.
Source - C# language versioning
我一直在寻找 .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:
您可以在 Microsoft 的参考。
You can find a list of all the C# language versions on Microsoft's reference.