Difference between C# compiler version and language version

 
 

As nobody gives a good enough answer, I will have a try now.

First, C# has its version history published by Microsoft now (coming from MVP posts obviously),

https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history

So you can easily see what new features are added for each new releases.

Second, we will talk about the compiler releases, which initially were part of .NET Framework.

Below I list a few milestones (might not be 100% correct, and some versions might be skipped),

  • csc.exe 1.0 (?) for .NET Framework 1.0 (implements C# 1.0).
  • csc.exe 2.0 (Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.8745) for .NET Framework 2.0 (implements C# 2.0, as well as 1.0 for compatibility).
  • csc.exe 3.5 (Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.8763) for .NET Framework 3.5 (implements C# 3.0, and older versions).
  • csc.exe 4.0 (?) for .NET Framework 4.0 (implements C# 4.0, and older).
  • csc.exe 4.x (like Microsoft (R) Visual C# Compiler version 4.7.2053.0) for .NET Framework 4.5 and above (implements C# 5.0, and older). Note that the version numbers vary a lot (from 4.x to 12.x) based on the .NET Framework on your machine (4.5.0 to 4.7.1).

Then Microsoft made the old csc.exe obsolete (as they were native executable), and shipped Roslyn based compiler instead (though still csc.exe). In the meantime, C# compiler is no longer part of .NET Framework, but part of VS.

It was the same time, that C# compiler, language version, and .NET Framework are fully decoupled, so that you can easily use multi-targeting.

  • Roslyn csc.exe 1.x (?) implements C# 6.0 and older. Shipped with VS2015.
  • Roslyn csc.exe 2.x (like Microsoft (R) Visual C# Compiler version 2.4.0.62122 (ab56a4a6)) implements C# 7.x and older. Shipped with VS2017.

Ok, enough background. Back to your questions.

Q1: How to find out what C# version (not the compiler one, but the language one) uses VS to build my concrete project?

Answer: You can easily see from project settings that what language version is used.

If you don't choose an explicit version, it can automatically use the latest version supported by the csc.exe compiling the project.

Note that @Servy commented under @DaniloCataldo's answer about the langversion switch with more details. That switch has its design goals and limitation. So for example even if you force Roslyn 2.x compiler to compile your project based on C# 4.0, the compiled result would be different from what C# 4.0 compiler does.

Q2: Is there a strict, clear and transparent link between the C# compiler and language versions?

Answer: Please refer to the background I described above, I think that already answered this part. There is a strict, clear and transparent link.

Q3: Can I indicate to Visual Studio (in case of migration issues from one Studio version to another) to use different compiler version for my concrete solution?

Answer: Duplicate to Q1.

Difference between C# compiler version and language version的更多相关文章

  1. swift 第三方库迁移错误解决“Use Legacy Swift Language Version” (SWIFT_VERSION) is required to be configured correctly for targets which use Swift. Use the [Edit > Convert > To Current Swift Syntax…] menu to choo

    先看看错误提示 这里Alamofire库报错,原因打开工程会Xcode会提示你覆盖到最新的3.0版本.但是仍然有些框架会出现一些问题 解决办法: 选择Pods - ReactiveCocoa - Sw ...

  2. “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift

    使用cocopod导入第三方swift包后,编译报以下错误: The "Swift Language Version" (SWIFT_VERSION) build setting ...

  3. What is the difference between apache tomcat deployer and core version? - Stack Overflow

    java - What is the difference between apache tomcat deployer and core version? - Stack Overflowhttps ...

  4. swift语言版本选择 - 解决XCode报错:The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported valu

    转发链接:https://blog.csdn.net/nathan1987_/article/details/79757368 The “Swift Language Version” (SWIFT_ ...

  5. 解决linux下javac -version和java -version版本显示不一致

    解决linux下javac -version和java -version版本显示不一致 [javascript] view plaincopy [root@localhost usr]# $JAVA_ ...

  6. 解决maven web项目Cannot detect Web Project version. Please specify version of Web Project through...的错误

    前面已经创建maven web工程,但是问题来了,创建maven web工程之后会出现如下的错误,在pom.xml文件头部 有以下的错误 Description Resource Path Locat ...

  7. 解决Maven web 项目 Cannot detect Web Project version. Please specify version of Web Project through ... 的错误

    创建maven项目的时候,maven文件头报错: Cannot detect Web Project version. Please specify version of Web Project th ...

  8. nginx的Mainline version、Stable version、Legacy version的版本区别

    nginx的Mainline version.Stable version.Legacy version的版本区别 创建时间:2014-01-16 10:30:37最后修改:2014-09-23 20 ...

  9. /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.5.3/lib/cocoapods/command.rb:118:in `git_version': Failed to extract git version from `git --version`

    问题及分析 今天做项目的时候,执行pod update报了如下错误信息: /usr/local/lib/ruby/gems/2.4.0/gems/cocoapods-1.5.3/lib/cocoapo ...

随机推荐

  1. Scala语言基础

    1. Scala语言的特点 a. 多范式编程语言,面向对象(抽象.封装)和函数式(过程.结果)编程 b. 代码简洁 ==>可读性较差 c. 代码会被变异成Java字节码,运行在JVM上 2. S ...

  2. 底部版权时间自动变化,网页在线qq咨询

    <p><small>© 众筹网<script>document.write(new Date().getFullYear());</script> &l ...

  3. python基础:if判断与流程控制案例

    # 1.使用while循环输出1 2 3 4 5 6 8 9 10 count = 0 while count < 11: if count == 7: count += 1 continue ...

  4. PAT Basic 1061 判断题 (15 分)

    判断题的评判很简单,本题就要求你写个简单的程序帮助老师判题并统计学生们判断题的得分. 输入格式: 输入在第一行给出两个不超过 100 的正整数 N 和 M,分别是学生人数和判断题数量.第二行给出 M ...

  5. Java调用和回调总结(2)

    Java调用和回调总结(2) 调用的种类 调用有3种, 普通调用(同步调用), 异步调用, 异步回调. 三种调用的特点 普通调用: 也叫做同步调用 , 最常见的调用, 会造成阻塞. 异步调用 : 异步 ...

  6. Physical Education Lessons CodeForces - 915E (动态开点线段树)

    Physical Education Lessons CodeForces - 915E This year Alex has finished school, and now he is a fir ...

  7. 【Java基础 项目实例--Bank项目5】Account 和 customer 对象等 继承、多态、方法的重写

    延续 Java基础 项目实例--Bank项目4 实验要求 实验题目 5: 在银行项目中创建 Account 的两个子类:SavingAccount 和 CheckingAccount 实验目的: 继承 ...

  8. 【转】Everything you need to know about NoSQL databases

    原文: https://dev.to/lmolivera/everything-you-need-to-know-about-nosql-databases-3o3h ---------------- ...

  9. string::capacity string::size string::length string::max_size

    size_t capacity() const noexcept; #include <iostream>#include <string> using namespace s ...

  10. 从mysql8.0读取数据并形成pandas dataframe类型数据,精确定位行列式中的元素,并读取

    from pandas import * import pandas as pd from sqlalchemy import create_engine engine = create_engine ...