.NET Core使用哪个C#版本?

Which C# version .NET Core uses?

我知道C版本依赖于.NET框架。

但是.NET核心使用哪个版本?

尤其是.NET核心2?C?7?


.NET Core 2.0引用了Roslyn 2.3,它对应于Visual Studio 2017版本15.3,并支持C 7.1。


C What's New页面列出了所有版本及其关联的Visual Studio和.NET核心版本:

  • C# 7.3 Visual Studio 2017 version 15.7, and in the .NET Core 2.1 SDK 2.1.300 RC1
  • C# 7.2 Visual Studio 2017 version 15.5, and in the .NET Core 2.0 SDK.
  • C# 7.1 Visual Studio 2017 version 15.3, and in the .NET Core 2.0 SDK.
  • C# 7.0 Visual Studio 2017 and .NET Core 1.0 and later

您可以使用以下命令使用您的SDK版本:

1
dotnet --info

输出:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
.NET Core SDK (reflecting any global.json):
 Version:   2.1.300
 Commit:    adab45bf0c

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.300/

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba

.NET Core SDKs installed:
  2.1.300 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]


来自Microsoft.NET核心Whats新页面:

NET Core 2.0 supports C# 7.1, which adds a number of new features, including:

  • The Main method, the application entry point, can be marked with the async keyword.
  • Inferred tuple names.
  • Default expressions.