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

标签 c# .net visual-studio .net-framework-version compiler-version

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

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

最佳答案

C#语言版本历史:
这些是 versions of C#在撰写本文时已知:

  • C# 1.0 随 .NET 1.0 和 VS2002 一起发布(2002 年 1 月)
  • C# 1.2 (够奇怪的);随 .NET 1.1 和 VS2003(2003 年 4 月)一起发布。第一个版本调用 DisposeIEnumerator s 实现了 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 月)一起发布。主要新特性:后期绑定(bind)(dynamic)、委托(delegate)和接口(interface)通用变量、更多的 COM 支持、命名参数、元组数据类型和可选参数
  • C# 5.0 随 .NET 4.5 和 VS2012(2012 年 8 月)一起发布。 Major features : 异步编程,来电信息属性。重大变更:loop variable closure .
  • C# 6.0 随 .NET 4.6 和 VS2015(2015 年 7 月)一起发布。实现者 Roslyn . Features :自动实现属性的初始化器,使用指令导入静态成员、异常过滤器、元素初始化器,awaitcatchfinally , 分机 Add集合初始值设定项中的方法。
  • C# 7.0 随 .NET 4.7 和 VS2017(2017 年 3 月)一起发布。少校 new features :tuples , ref locals and ref return , pattern matching (包括基于模式的 switch 语句),inline out parameter declarations , local functions , binary literals, digit separators , 和 arbitrary async returns .
  • C# 7.1 随 VS2017 v15.3 一起发布(2017 年 8 月)新特性:async main , tuple member name inference , default expression , pattern matching with generics .
  • C# 7.2 随 VS2017 v15.5 一起发布(2017 年 11 月)新特性:private protected access modifier , Span<T>, aka interior pointer, aka stackonly struct , everything else .
  • C# 7.3 随 VS2017 v15.7(2018 年 5 月)一起发布。新功能:enum, delegate and unmanaged generic type constraints . ref重新分配。不安全的改进:stackalloc初始化,未固定索引 fixed缓冲区,自定义 fixed声明。改进了重载分辨率。初始值设定项和查询中的表达式变量。 ==!=为元组定义。现在可以通过属性来定位自动属性的支持字段。
  • C# 8.0 随 .Net Core 3.0 和 VS2019 v16.3(2019 年 9 月)一起发布。少校 new features :nullable reference-types , Asynchronous streams , Indices and Ranges , Readonly members , using declarations , default interface methods , Static local functionsEnhancement of interpolated verbatim strings .
  • C# 9.0 .Net 5.0 一起发布和 VS2019 v16.8(2020 年 11 月)。少校 new features :init-only properties , records , with-expressions ,数据类,位置记录,top-level programs , improved pattern matching (简单类型模式、关系模式、逻辑模式)、改进的目标类型(目标类型 new 表达式、目标类型 ???)、协变返回。小功能:放宽 ref 的订购和 partial修饰符、参数空检查、lambda 丢弃参数、 native int s、局部函数的属性、函数指针、静态 lambda、扩展 GetEnumerator , 模块初始值设定项,扩展部分。

  • 回应 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# 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(例如 this MSDN page 用来指代它),但 Environment.Version 属性仍然报告 4.0.xxx。
    截至 2017 年 5 月 3 日,C# 语言团队在其 GitHub 存储库中创建了 C# 版本和功能的历史记录:Features Added in C# Language Versions .还有a page that tracks upcoming and recently implemented language features .

    关于c# - C# 的正确版本号是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/247621/

    相关文章:

    visual-studio - 如何避免监视列表变量在 Visual Studio 中的值更改时崩溃?

    c# - 如何添加实体列表以及如何获取 ID

    c# - 如何分配游戏对象的 x 和 y 位置?

    c# - HTTP 错误 404.15 - 未找到

    .net - WCF REST 服务客户端调用映射到错误的 Uris

    c# - 如何设置剪贴板来复制文件?

    visual-studio - 云中的 Visual Studio?

    c# - 如何在 C# .NET 中反序列化复杂的 JSON 对象?

    c# - ASP.NET MVC 3 中的更新面板

    c# - 在 IronPython 中使用 C# 代码