Difference between C# compiler version and language version

前端 未结 4 1523
天命终不由人
天命终不由人 2020-12-24 08:08

There was time I thought that the Framework version and the C# version are the same things, so once you install the next Framework version on the computer, you should use it

4条回答
  •  轮回少年
    2020-12-24 08:42

    In the past Visual Studio 2005 was fixed only to one .Net version and C# compiler delivered with this version. In case you want use newer version of VS you have to switch Visual Studio as well. Now Visual studio can target to more than one .Net version and it can even mix new C# compiler with old .Net framework (lambdas or extension methods in .Net 2.0). Simply C# compiler version is related to C# language version.

    You can check your compiler version in project file (open it as xml) and there is ToolsVersion attribute of Project element.

    In my specific project there is ToolsVersion="4.0" and my target project is .Net 2.0. It means I can use new language construct in old framework which is not possible in VS2005.

提交回复
热议问题