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

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

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


#1楼

比较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 。 尽管应注意,与.NET 3.5对应的C#在msdn.microsoft.com中被命名为“ Visual C#2008 Service Pack 1”

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

C#2.0Visual C#2005的同义词

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


#2楼

C#语言版本历史记录:

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

针对OP的问题:

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

没有C#3.5这样的东西-造成混淆的原因是.NET 3.5中存在C#3.0。 但是,语言和框架的版本是独立的-CLR的版本是.NET 2.0到3.5的2.0版,引入了CLR 4.0的.NET 4带有Service Pack。 .NET 4.5中的CLR进行了各种改进,但是版本控制尚不清楚:在某些地方,它可能被称为CLR 4.5(例如, 此MSDN页面曾经以这种方式引用它),但是Environment.Version属性仍然报告4.0.xxx。

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


#3楼

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


#4楼

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

C# 1.0 / 1.2 ____ 2001年12月 / 2003 ___________ 2002年1月

C#2.0 _______ 2005年9月 ________________ 2005 11月

C#3.0 _______ 2006年5月 _____________________ 2006 11月

C#4.0 _______ 2009年3月(草稿) ______________ 2010年4月

C#5.0; .NET 4.5于2012年8月发布

C#6.0; .NET 4.6 2015发行

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


#5楼

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


#6楼

C#版本历史:

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

自2002年首次发布以来,C#有了很大的发展。.NETFramework 1.0引入了C#。

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

在此处输入图片说明

C#版本中提供了最新版本的C#。


#7楼

这与此处的大多数答案相同,但为方便起见将其制成表格,并且具有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    ║              ║             ║   Apr 2019   ║    
╚════════════╩════════════╩══════════════╩═════════════╩══════════════╝

注意:如今,.NET开发几乎独立于VS,每个版本之间都没有关联。 有关更多信息,请参考“ .NET Framework版本和依赖关系 ”。


#8楼

我已经总结了此表中的大多数版本。 唯一缺少的应该是ASP.NET Core版本。 我还添加了不同版本的ASP.NET MVC。

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

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

版


#9楼

  • 带有Visual Studio.NET的C#1.0

  • 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

  • Visual Studio 2019中的C#8.0 (预览)


#10楼

C#1.0-Visual Studio .NET 2002

Classes
Structs
Interfaces
Events
Properties
Delegates
Expressions
Statements
Attributes
Literals

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年

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

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

C#5-Visual Studio 2012

    Asynchronous methods
    Caller info attributes

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年

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版本15.3

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

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版本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和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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值