Is using the keyword var bad in C# 2.0?

Posted by Patrick on Stack Overflow See other posts from Stack Overflow or by Patrick
Published on 2010-04-29T10:15:17Z Indexed on 2010/04/29 10:17 UTC
Read the original article Hit count: 364

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about compiler