简体   繁体   English

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

[英]Which C# version .NET Core uses?

I know that C# version depends on .NET Framework .我知道C# 版本取决于 .NET Framework

But .NET Core which version uses?但是.NET Core 使用哪个版本呢?

Particularly .NET Core 2?特别是.NET Core 2? C#7? C#7?

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

The C# what's new version history page gives a list of all versions plus their associated Visual Studio and .NET core version: 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.3 Visual Studio 2017 版本 15.7,在 .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.2 Visual Studio 2017 版本 15.5,在 .NET Core 2.0 SDK 中。
  • C# 7.1 Visual Studio 2017 version 15.3, and in the .NET Core 2.0 SDK. C# 7.1 Visual Studio 2017 版本 15.3,在 .NET Core 2.0 SDK 中。
  • C# 7.0 Visual Studio 2017 and .NET Core 1.0 and later C# 7.0 Visual Studio 2017 和 .NET Core 1.0 及更高版本

C# 8.0 is still in preview at this time (3-Jul-2019). C# 8.0 目前仍处于预览阶段(2019 年 7 月 3 日)。

You can also see your SDK version with this command:您还可以使用以下命令查看您的 SDK 版本:

dotnet --info

Sample output:示例输出:

.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]

From Microsoft .net core what's new page :来自 Microsoft .net core的新页面

NET Core 2.0 supports C# 7.1, which adds a number of new features, including: NET Core 2.0 支持 C# 7.1,它增加了许多新功能,包括:

  • The Main method, the application entry point, can be marked with the async keyword. Main 方法,即应用程序入口点,可以使用 async 关键字进行标记。
  • Inferred tuple names.推断的元组名称。
  • Default expressions.默认表达式。

You can also review check the C# Language versioning page您还可以查看检查C# 语言版本控制页面

The compiler determines a default based on these rules:编译器根据以下规则确定默认值:

.NET Core 2.x C# 7.3 .NET 核心 2.x C# 7.3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM