协慌网

登录 贡献 社区

C#的正确版本号是什么?

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

这个问题主要是为了帮助那些使用不正确的版本号搜索答案的人,例如C#3.5 。希望是任何未能找到错误版本号的答案的人都会找到这个问题,然后再使用正确的版本号进行搜索。

答案

C# language version history:

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

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.

More detailed information about the relationship between the language, runtime and framework versions is available on the C# in Depth site. This includes information about which features of C# 3.0 you can use when targeting .NET 2.0. (If anyone wants to bring all of the content into this wiki answer, they're welcome to.)

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

处理 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 语法和功能。

这与大多数答案相同,但是为了方便而制表,并且它具有 Visual Studio 和. NET 版本以实现完整性。

╔════════════╦════════════╦══════════════╦═════════════╦══════════════╗
║ 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   ║
║    5.0     ║    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   ║
╚════════════╩════════════╩══════════════╩═════════════╩══════════════╝

注意:.NET 开发现在几乎与 VS 无关,每个版本之间没有相关性。有关更多信息,请参阅: https//docs.microsoft.com/en-us/dotnet/framework/migration-guide/versions-and-dependencies