C# 中的新增功能What's new in C#

本页介绍了 C# 语言每个主要版本中新增功能的路线图。This page provides a roadmap of new features in each major release of the C# language. 链接的文章详细介绍了每个版本中增加的主要功能。The linked articles detail information on the major features added in each release. 可以在常规版本或公共预览版中找到有关已发布新功能的信息。You will find information on new features that have been released, either in a general release, or in a public preview. 可以在 GitHub 上的 dotnet/roslyn 存储库上找到详细的语言功能状态,包括考虑在即将发布的版本中添加的功能。Detailed language feature status, including features considered for upcoming releases can be found on the dotnet/roslyn repository on GitHub.

重要

为了提供一些功能,C# 语言依赖标准库中的类型和方法。The C# language relies on types and methods in a standard library for some of the features. 例如,异常处理。One example is exception processing. 为了确保引发的对象派生自 Exception,将会检查每个 throw 语句或表达式。Every throw statement or expression is checked to ensure the object being thrown is derived from Exception. 同样,还会检查每个 catch,以确保捕获的类型派生自 ExceptionSimilarly, every catch is checked to ensure that the type being caught is derived from Exception. 每个版本都可能会新增要求。Each version may add new requirements. 若要在旧版环境中使用最新语言功能,可能需要安装特定库。To use the latest language features in older environments, you may need to install specific libraries. 每个特定版本的页面中记录了这些依赖项。These dependencies are documented in the page for each specific version. 若要了解此依赖项的背景信息,可以详细了解语言与库的关系You can learn more about the relationships between language and library for background on this dependency.

若要使用单点版本中的最新功能,需要配置编译器语言版本并选择版本。To use the latest features in a point release, you need to configure the compiler language version and select the version.

早期版本Previous Versions

下面列出了在以前版本的 C# 语言和 Visual Studio.NET 中引入的主要功能。The following lists key features that were introduced in previous versions of the C# language and Visual Studio .NET.

  • Visual Studio .NET 2013:Visual Studio .NET 2013:
    • 此版本的 Visual Studio 包含 .NET Compiler Platform(“Roslyn”)的 Bug 修复、性能改进和技术预览,Roslyn 是 .NET Compiler Platform SDK 的前身。This version of Visual Studio included bug fixes, performance improvements, and technology previews of .NET Compiler Platform ("Roslyn") which became the .NET Compiler Platform SDK.
  • C# 5,Visual Studio .NET 2012:C# 5, Visual Studio .NET 2012:
  • C# 4,Visual Studio .NET 2010:C# 4, Visual Studio .NET 2010:
  • C# 3,Visual Studio .NET 2008:C# 3, Visual Studio .NET 2008:
    • 对象和集合初始值设定项、lambda 表达式、扩展方法、匿名类型、自动属性、本地 var 类型推理和语言集成查询 (LINQ)Object and collection initializers, lambda expressions, extension methods, anonymous types, automatic properties, local var type inference, and Language Integrated Query (LINQ).
  • C# 2,Visual Studio .NET 2005:C# 2, Visual Studio .NET 2005:
    • 匿名方法、泛型、可以为 null 的类型、迭代器/yield、static 类、委托的协变和逆变。Anonymous methods, generics, nullable types, iterators/yield, static classes, and covariance and contra variance for delegates.
  • C# 1.1,Visual Studio .NET 2003:C# 1.1, Visual Studio .NET 2003:
    • #line 杂注和 xml 文档注释。#line pragma and xml doc comments.
  • C# 1,Visual Studio .NET 2002:C# 1, Visual Studio .NET 2002:
    • C# 初版。The first release of C#.