C# 的正确版本号是多少?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/247621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 19:45:09  来源:igfitidea点击:

What are the correct version numbers for C#?

c#.netvisual-studio.net-framework-versioncompiler-version

提问by Jon Skeet

What are the correct version numbers for C#? What came out when? Why can't I find any answers about C# 3.5?

C# 的正确版本号是多少?什么时候出来的?为什么我找不到有关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 thisquestion and then search again with the right version number.

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

采纳答案by Jon Skeet

C# language version history:

C#语言版本历史:

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

这些是撰写本文时已知的 C# 版本

  • C# 1.0随 .NET 1.0 和 VS2002 一起发布(2002 年 1 月)
  • C# 1.2(很奇怪);随 .NET 1.1 和 VS2003(2003 年 4 月)一起发布。第一个版本的呼叫DisposeIEnumerator该实施小号IDisposable。其他一些小功能。
  • C# 2.0随 .NET 2.0 和 VS2005 一起发布(2005 年 11 月)。主要新特性:泛型、匿名方法、可为空类型、迭代器块
  • C# 3.0随 .NET 3.5 和 VS2008 一起发布(2007 年 11 月)。主要新特性:lambda 表达式、扩展方法、表达式树、匿名类型、隐式类型 ( var)、查询表达式
  • C# 4.0随 .NET 4 和 VS2010 一起发布(2010 年 4 月)。主要新特性:后期绑定 ( dynamic)、委托和接口泛型变化、更多 COM 支持、命名参数、元组数据类型和可选参数
  • C# 5.0随 .NET 4.5 和 VS2012 一起发布(2012 年 8 月)。主要功能:异步编程,来电信息属性。重大变化:循环变量闭包
  • C# 6.0随 .NET 4.6 和 VS2015 一起发布(2015 年 7 月)。由罗斯林实施。特性:自动实现属性的初始化器,使用指令导入静态成员,异常过滤器,元素初始化器,awaitincatchfinallyAdd集合初始化器中的扩展方法。
  • C# 7.0随 .NET 4.7 和 VS2017 一起发布(2017 年 3 月)。主要新特性元组ref locals 和 ref return模式匹配(包括基于模式的 switch 语句)、内联out参数声明本地函数二进制文字、数字分隔符任意异步返回
  • C# 7.1随 VS2017 v15.3 一起发布(2017 年 8 月) 新特性:async main元组成员名称推断默认表达式与泛型的模式匹配
  • C# 7.2随 VS2017 v15.5 一起发布(2017 年 11 月) 新功能:私有保护访问修饰符Span<T>、又名内部指针、又名 stackonly 结构其他所有内容
  • C# 7.3随 VS2017 v15.7 一起发布(2018 年 5 月)。新特性:枚举、委托和unmanaged泛型类型约束ref重新分配。不安全的改进:stackalloc初始化、未固定索引fixed缓冲区、自定义fixed语句。改进了重载分辨率。初始值设定项和查询中的表达式变量。==!=为元组定义。现在可以通过属性来定位自动属性的支持字段。
  • C# 8.0随 .Net Core 3.0 和 VS2019 v16.3 一起发布(2019 年 9 月)。主要新特性可为空的引用类型异步流索引和范围只读成员使用声明默认接口方法静态本地函数内插逐字字符串的增强
  • C# 9.0仍处于预览阶段。预计将于 2020 年 11 月与 .Net 5 一起发布。主要的新特性:init-only 属性、记录、with 表达式、数据类、位置记录、顶级程序、改进的模式匹配(简单类型模式、关系模式、逻辑模式)、改进的目标类型(目标类型new表达式、目标类型???),协变返回。次要功能:放宽refpartial修饰符的排序、参数空检查、lambda 丢弃参数、本机ints、本地函数的属性、函数指针、静态 lambda、扩展GetEnumerator、模块初始值设定项、扩展部分。

In response to the OP's question:

回应 OP 的问题:

What are the correct version numbers for C#? What came out when? Why can't I find any answers about C# 3.5?

C# 的正确版本号是多少?什么时候出来的?为什么我找不到有关 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 pageused to refer to it that way, for example), but the Environment.Versionproperty still reports 4.0.xxx.

没有像 C# 3.5 这样的东西 - 这里混淆的原因是 C# 3.0 存在于 .NET 3.5 中。然而,语言和框架的版本是独立的 - 就像 CLR 一样,它是 2.0 版,用于 .NET 2.0 到 3.5,.NET 4 引入了 CLR 4.0,尽管有服务包。.NET 4.5 中的 CLR 有各种改进,但版本控制尚不清楚:在某些地方,它可能被称为 CLR 4.5(例如,这个 MSDN 页面曾经以这种方式引用它),但该Environment.Version属性仍然报告 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.

截至 2017 年 5 月 3 日,C# 语言团队在其 GitHub 存储库中创建了 C# 版本和功能的历史记录:在 C# 语言版本中添加的功能。还有一个页面可以跟踪即将推出和最近实施的语言功能

回答by Bryan Rehbein

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.

处理 C# 版本号时的最大问题是它与 .NET Framework 的版本无关,这似乎是由于 Visual Studio 和 .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, C99describe the code syntax/features for C.

C# 的版本实际上绑定到编译器,而不是框架。例如,在 Visual Studio 2008 中,您可以编写 C# 3.0 并针对 .NET Framework 2.0、3.0 和 3.5。C# 3.0 命名法描述了代码语法版本和支持的功能,其方式与ANSI C89、C90、C99描述 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.

看看Mono,您会看到 Mono 2.0(主要是根据 ECMA 规范实现的 .NET Framework 2.0 版)支持 C# 3.0 语法和功能。

回答by Pramodh

VERSION_____LANGUAGE SPECIFICATION______MICROSOFT COMPILER

版本_____语言规范______微软编译器

C# 1.0/1.2____December 2001?/2003?___________January 2002?

C# 1.0/ 1.2____2001 年 12 月/2003 年___________2002 年 1 月

C# 2.0_______September 2005________________November 2005?

C# 2.0 _______2005________________9 月 2005 年11 月

C# 3.0_______May 2006_____________________November 2006?

C# 3.0 _______2006_____________________5 月 2006 年11 月

C# 4.0_______March 2009 (draft)______________April 2010?

C# 4.0 _______2009 年 3 月(草案)______________2010 年 4 月

C# 5.0; released with .NET 4.5 in August 2012

C# 5.0; 2012 年 8 月随 .NET 4.5 一起发布

C# 6.0; released with .NET 4.6 2015

C# 6.0; 随 .NET 4.6 2015 一起发布

C# 7.0; released with .NET 4.7 2017

C# 7.0; 随 .NET 4.7 2017 一起发布

C# 8.0; released with .NET 4.8 2019

C# 8.0; 随 .NET 4.8 2019 一起发布

回答by iTSrAVIE

  • C# 1.0with Visual Studio.NET

  • C# 2.0with Visual Studio 2005

  • C# 3.0with Visual Studio 2008

  • C# 4.0with Visual Studio 2010

  • C# 5.0with Visual Studio 2012

  • C# 6.0with Visual Studio 2015

  • C# 7.0with Visual Studio 2017

  • C# 8.0with Visual Studio 2019

  • C# 1.0和 Visual Studio.NET

  • C# 2.0和 Visual Studio 2005

  • C# 3.0和 Visual Studio 2008

  • C# 4.0与 Visual Studio 2010

  • C# 5.0和 Visual Studio 2012

  • C# 6.0与 Visual Studio 2015

  • C# 7.0与 Visual Studio 2017

  • C# 8.0和 Visual Studio 2019

回答by Gennady Vanin Геннадий Ванин

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.

比较 MSDN 文章“What's New in the C# 2.0 Language and Compiler”和“ What's New in Visual C# 2005”,可以推断出“C#major_version.minor_version”是根据编译器的版本编号创造的。

There is C# 1.2 corresponding to .NET 1.1 and VS 2003and also named as Visual C# .NET 2003.

对应于 .NET 1.1 和 VS 2003 的 C# 1.2,也称为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".

但进一步,微软停止增加次要版本(在点之后)数字或让它们不是零,0. 但需要注意的是,对应于 .NET 3.5 的 C# 在 msdn.microsoft.com 中被命名为“Visual C# 2008 Service Pack 1”

There are two parallel namings: By major .NET/compiler version numbering and by Visual Studio numbering.

有两种并行命名:按主要 .NET/编译器版本编号和按 Visual Studio 编号。

C# 2.0is a synonym for Visual C# 2005

C# 2.0Visual C# 2005的同义词

C# 3.0 corresponds (or, more correctly, can target) to:

C# 3.0 对应(或更准确地说,可以定位)为:

回答by Israel Ocbina

You can check the latest C# versions hereC# Versions

您可以在此处查看最新的 C# 版本C# 版本

回答by Milan

C# Version History:

C# 版本历史:

C# is a simple and powerful object-oriented programming language developed by Microsoft.

C#是微软开发的一种简单而强大的面向对象的编程语言。

C# has evolved much since its first release in 2002. C# was introduced with .NET Framework 1.0.

自 2002 年首次发布以来,C# 已经发展了很多。C# 是随 .NET Framework 1.0 引入的。

The following table lists important features introduced in each version of C#.

下表列出了每个 C# 版本中引入的重要功能。

And the latest version of C# is available in C# Versions.

最新版本的 C# 可在C# Versions 中获得

1: enter image description here

1在此处输入图片说明

回答by nawfal

This is the same as most answers here, but tabularized for ease, and it has Visual Studioand .NETversions for completeness.

这与此处的大多数答案相同,但为便于表格化,并且为了完整起见,它具有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   ║
║    8.0     ║    2019    ║    4.8       ║     4       ║   Apr 2019   ║    
╚════════════╩════════════╩══════════════╩═════════════╩══════════════╝

Note:.NET development is pretty much independent of VS these days, there is no correlation between versions of each.
Refer to ".NET Framework versions and dependencies" for more.

注意:.NET 开发现在几乎独立于 VS,每个版本之间没有相关性。
有关更多信息,请参阅“ .NET Framework 版本和依赖项”。

回答by Mindless

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.

我已经总结了这个表中的大部分版本。唯一缺少的应该是 ASP.NET Core 版本。我还添加了不同版本的 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.

请注意,ASP.NET 5 已更名为 ASP.NET Core 1.0,ASP.NET MVC 6 已更名为 ASP.NET Core MVC 1.0.0。我相信这种变化发生在 2016 年 1 月左右。

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?

我已经在表中包含了 ASP.NET 5 RC1 的发布日期,但我还没有包含 ASP.NET 核心 1.0 和其他核心版本,因为我找不到确切的发布日期。您可以在此处阅读有关 ASP.NET Core 发布日期的更多信息:ASP.NET Core 1.0 (ASP.NET 5 / vNext) 何时发布?

Version

版本

回答by sayah imad

C# 1.0 - Visual Studio .NET 2002

C# 1.0 - Visual Studio .NET 2002

Classes
Structs
Interfaces
Events
Properties
Delegates
Expressions
Statements
Attributes
Literals

C# 1.2 - Visual Studio .NET 2003

C# 1.2 - Visual Studio .NET 2003

Dispose in foreach
foreach over string specialization
C# 2 - Visual Studio 2005
Generics
Partial types
Anonymous methods
Iterators
Nullable types
Getter/setter separate accessibility
Method group conversions (delegates)
Static classes
Delegate inference

C# 3 - Visual Studio 2008

C# 3 - Visual Studio 2008

Implicitly typed local variables
Object and collection initializers
Auto-Implemented properties
Anonymous types
Extension methods
Query expressions
Lambda expression
Expression trees
Partial methods

C# 4 - Visual Studio 2010

C# 4 - Visual Studio 2010

Dynamic binding
Named and optional arguments
Co- and Contra-variance for generic delegates and interfaces
Embedded interop types ("NoPIA")

C# 5 - Visual Studio 2012

C# 5 - Visual Studio 2012

    Asynchronous methods
    Caller info attributes

C# 6 - Visual Studio 2015

C# 6 - Visual Studio 2015

Draft Specification online
Compiler-as-a-service (Roslyn)
Import of static type members into namespace
Exception filters
Await in catch/finally blocks
Auto property initializers
Default values for getter-only properties
Expression-bodied members
Null propagator (null-conditional operator, succinct null checking)
String interpolation
nameof operator
Dictionary initializer

C# 7.0 - Visual Studio 2017

C# 7.0 - Visual Studio 2017

Out variables
Pattern matching
Tuples
Deconstruction
Discards
Local Functions
Binary Literals
Digit Separators
Ref returns and locals
Generalized async return types
More expression-bodied members
Throw expressions

C# 7.1 - Visual Studio 2017 version 15.3

C# 7.1 - Visual Studio 2017 版本 15.3

Async main
Default expressions
Reference assemblies
Inferred tuple element names
Pattern-matching with generics

C# 7.2 - Visual Studio 2017 version 15.5

C# 7.2 - Visual Studio 2017 版本 15.5

Span and ref-like types
In parameters and readonly references
Ref conditional
Non-trailing named arguments
Private protected accessibility
Digit separator after base specifier

C# 7.3 - Visual Studio 2017 version 15.7

C# 7.3 - Visual Studio 2017 版本 15.7

System.Enum, System.Delegate and unmanaged constraints.
Ref local re-assignment: Ref locals and ref parameters can now be reassigned with the ref assignment operator (= ref).
Stackalloc initializers: Stack-allocated arrays can now be initialized, e.g. Span<int> x = stackalloc[] { 1, 2, 3 };.
Indexing movable fixed buffers: Fixed buffers can be indexed into without first being pinned.
Custom fixed statement: Types that implement a suitable GetPinnableReference can be used in a fixed statement.
Improved overload candidates: Some overload resolution candidates can be ruled out early, thus reducing ambiguities.
Expression variables in initializers and queries: Expression variables like out var and pattern variables are allowed in field initializers, constructor initializers and LINQ queries.
Tuple comparison: Tuples can now be compared with == and !=.
Attributes on backing fields: Allows [field: …] attributes on an auto-implemented property to target its backing field.

C# 8.0 - .NET Core 3.0 and Visual Studio 2019 version 16.3

C# 8.0 - .NET Core 3.0 和 Visual Studio 2019 版本 16.3

Nullable reference types: express nullability intent on reference types with ?, notnull constraint and annotations attributes in APIs, the compiler will use those to try and detect possible null values being dereferenced or passed to unsuitable APIs.
Default interface members: interfaces can now have members with default implementations, as well as static/private/protected/internal members except for state (ie. no fields).
Recursive patterns: positional and property patterns allow testing deeper into an object, and switch expressions allow for testing multiple patterns and producing corresponding results in a compact fashion.
Async streams: await foreach and await using allow for asynchronous enumeration and disposal of IAsyncEnumerable<T> collections and IAsyncDisposable resources, and async-iterator methods allow convenient implementation of such asynchronous streams.
Enhanced using: a using declaration is added with an implicit scope and using statements and declarations allow disposal of ref structs using a pattern.
Ranges and indexes: the i..j syntax allows constructing System.Range instances, the ^k syntax allows constructing System.Index instances, and those can be used to index/slice collections.
Null-coalescing assignment: ??= allows conditionally assigning when the value is null.
Static local functions: local functions modified with static cannot capture this or local variables, and local function parameters now shadow locals in parent scopes.
Unmanaged generic structs: generic struct types that only have unmanaged fields are now considered unmanaged (ie. they satisfy the unmanaged constraint).
Readonly members: individual members can now be marked as readonly to indicate and enforce that they do not modify instance state.
Stackalloc in nested contexts: stackalloc expressions are now allowed in more expression contexts.
Alternative interpolated verbatim strings: @$"..." strings are recognized as interpolated verbatim strings just like $@"...".
Obsolete on property accessors: property accessors can now be individually marked as obsolete.
Permit t is null on unconstrained type parameter

[source] :https://github.com/dotnet/csharplang/blob/master/Language-Version-History.md

[来源]:https : //github.com/dotnet/csharplang/blob/master/Language-Version-History.md