Does C# 6.0 support .net core, or .net core responds to higher version of C#?

I've just installed .net core 1.0 and run the sample hello world. My question:

  1. Is there any relationship with .net core 1.0 and its default C# version?
  2. How can I know the C# version of this .net core installation, by any command line utilities?
Jon Skeet
people
quotationmark

The language itself isn't generally tied to a specific runtime/framework, although some language features do require framework features. (For example, interpolated strings are a bit more flexible on .NET 4.6 than on .NET 2.0 due to the presence of FormattableString.) However, there are two things to consider:

  • The version of the C# compiler supported by the SDK you've installed (dotnet cli)
  • The version of the C# compiler packages that is supported by a particular framework version

The SDK supports C# 6 out of the box. I would personally expect the C# 7 version of the Roslyn packages to support .NET Core as well (e.g. targeting netstandard1.5), so code that compiles more code at execution time should be fine on that front. I don't know what the plan is in terms of tying compiler versions to SDK versions - I suspect that will become clearer when the project.json to msbuild transition is complete.

I don't know of any way of determining what language version a particular SDK supports out of the box - it would be reasonably easy to come up with a sequence of small classes which exercise particular language features and see if they compile, of course. Trickier would be to come up with code that builds with multiple versions but gives different results; there are ways of doing that between consecutive language versions (at least 2-3, 3-4, 4-5... not sure about 5-6) but they're slightly more convoluted.

people

See more on this question at Stackoverflow