I'm getting a strange behavior in Visual Studio 2015. I'm writting an application targeting 4.5.2 .Net Framework:
Then in the application, I try use some things which were implemented in C# 6.0 (which is from .Net 6.0) :
int number = 456;
var name = nameof(number);
string str = $"Time = {DateTime.Now}";
I'm quite sure that nameof
and string formatting using $
are only available in .Net 4.6, but still I'm able to compile this code - event though I'm targeting 4.5.2.
I've run the same code in Visual Studio 2013, also targeting the 4.5.2 version, but this time I can't compile the code (nameof
not found).
How is it possible, that VS2015 allowed me to compile the code which shouldn't be allowed in target .Net Framework version?
My shoot in the dark is that the VS2015 is capable of computing the C# 6.0 code into the CIL which is still compatible with previous versions, but I'm not sure if it's the right guess.