这个问题主要是为了帮助那些使用错误版本号搜索答案的人,例如“ C#3.5”。希望任何未能找到正确答案的人都能找到这个问题,然后使用正确的版本号再次进行搜索。请保留原始HTML标签。
以下是此篇文章撰写时所知晓的C#语言版本:
Dispose
on IEnumerator
s which implemented IDisposable
. 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
in catch
and finally
, extension Add
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 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.new
expressions, target typed ??
and ?
), and covariant returns. Minor features: relax ordering of ref
and partial
modifiers, parameter null checking, lambda discard parameters, native int
s, attributes on local functions, function pointers, static lambdas, extension GetEnumerator
, 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, the CallerArgumentExpression
attribute for parameters, enhanced #line
pragmas.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 patternsC#的正确版本号是什么?每个版本发布时间是什么时候?为什么我找不到关于C# 3.5的任何答案?
其实不存在C# 3.5 - 这里的混淆原因在于C# 3.0出现在.NET 3.5中。然而,语言和框架的版本是独立的,而CLR也是如此。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# 版本 | VS 版本 | .NET 版本 | 发布日期 | 支持结束日期 |
---|---|---|---|---|
2015 更新3 | .NET Core 1.0 | 2016年6月 | 2019年6月 | |
.NET Core 1.1 | 2016年11月 | 2019年6月 | ||
7.0 | 2017 | 2017年3月 | ||
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年4月 | ||
2019(v16.3) | .NET Core 3.0 | 2019年9月 | 2020年3月 | |
2019(v16.4) | .NET Core 3.1 | 2019年12月 | 2022年12月 | |
9.0 | 2019(v16.8) | .NET 5 | 2020年11月 | N/A |
2020年11月 | 2022年5月 | |||
10.0 | 2022年 | .NET 6 | 2021年11月 | 2024年11月 |
11.0 | 2022年 (17.4) | .NET 7 | 2022年11月 | 2024年5月 |
.NET 8 | 2023年11月 | 2026年11月 |
* - .NET 5.0 不是 .NET 框架的新版本,而是 .NET Core 3 的新版本。从 .NET 5.0 开始,已经没有 .NET full framework 的新版本。
** - 针对 .NET Core,不存在单独的 CLR(CoreCLR)版本。 .NET Core 版本就是 CoreCLR 版本。因此不需要提及。
注意:.NET 和 VS、编译器版本基本上是独立的,它们之间没有关联。上面的列表不意味着某个 .NET 版本与某个 C# 或 VS 版本相关联。这只是按照它们发布的时间顺序进行编制的(VS/C# 和 .NET)。一些版本同时发布,因此它们位于同一行。
有关更多信息,请参阅“.NET Framework 版本和依赖项”和“.NET 发布节奏”。
使用 Visual Studio .NET 的 C# 1.0
使用 Visual Studio 2005 的 C# 2.0
使用 Visual Studio 2008 的 C# 3.0
使用 Visual Studio 2010 的 C# 4.0
使用 Visual Studio 2012 的 C# 5.0
使用 Visual Studio 2015 的 C# 6.0
使用 Visual Studio 2017 的 C# 7.0
使用 Visual Studio 2019 的 C# 8.0
使用 Visual Studio 2019 的 C# 9.0
将MSDN文章“C# 2.0语言和编译器的新特性”与“Visual C# 2005的新功能”进行比较,可以推断出“C# major_version.minor_version”是根据编译器的版本编号的名称。
有对应于.NET 1.1和VS 2003的C# 1.2,也称为Visual C# .NET 2003。
但是此后Microsoft停止增加次要版本(点号后面的版本号)或使其不为零,0
。尽管值得注意的是,在msdn.microsoft.com中对应于.NET 3.5的C#被命名为“Visual C# 2008 Service Pack 1”。
有两个并行的命名方式:根据主要.NET/编译器版本编号和根据Visual Studio编号。
C# 3.0对应(或更准确地说,可以定向到):
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
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