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.
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# 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
), 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.IAsyncEnumerable<T>
support, Ranges, and default interface methods.In 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.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.
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.