I read an article about using C# 3 features in C# 2 where you can for instance type var x = 2;
and even if the project is a 2.0 project, the Visual Studio 2008 compiler picks it up and generates the same code as it would if you type int x = 2
.
But what I don't get is, should you not do this in some cases? I always thought that the var
keyword didn't arrive until C# 3.. If the compiler generates the same code and I can type C# 3 code and C# 2 code exactly the same, what is the differance really, because the CLI is the same, right?
Quote from the link above
Behind the scenes, the compiler generate regular .NET 2.0 code.
Is there any difference between .NET 2.0 code and .NET 3 code?