What are the correct version numbers for C#?
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, eg 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.
These are the versions of C# known about at the time of this writing:
Dispose
on IEnumerator
s which implemented IDisposable
. A few other small features. var
), query expressions dynamic
), delegate and interface generic variance, more COM support, named arguments, tuple data type and optional parameters await
in catch
and finally
, extension Add
methods in collection initializers. out
parameter declarations, local functions, binary literals, digit separators, and arbitrary async returns. 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
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, C99 describe the code syntax/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 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
上一篇: .NET中decimal,float和double的区别?
下一篇: 什么是C#的正确版本号?