1

Say I have a web forms application built using visual studio 2015 using c# 6 syntax and targeting .NET framework version 4.5.

This is fine for everything that is delivered as DLLs because it's built in my build environment where I specify the language version and the target framework version in my csproj files.

When asp.net comes to compile my aspx pages in the runtime environment, it knows from the <compilation defaultLanguage="c#" targetFramework="4.5.1"/> in my web.config that it should be targeting the version 4.5.1 of the framework but how does it know what language version to use when invoking the compiler?

Andy
  • 10,412
  • 13
  • 70
  • 95
  • Well the `targetFramework` defines the version of C# as well. In your case, it would be C#. 5 See [this answer](http://stackoverflow.com/a/19532977/4802649). – Phiter Dec 19 '16 at 16:08
  • Or you can change C# version using this guide: https://www.codeproject.com/tips/865579/how-to-change-targeted-csharp-version-in-visual-st – Phiter Dec 19 '16 at 16:08
  • 1
    Thanks for the links but I'm not sure the answer is quite as straightforward as this. We know for a fact that there is not a 1:1 correspondence between C# version and framework version because I am writing c# 6.0 code today which targets .NET 4.5 and therefore will run on .NET 4.5 even though .NET 4.5 predates both visual studio 2015 and C# 6.0. – Andy Dec 20 '16 at 10:46

0 Answers0