Question

When I am working in .NET 2.0 projects with the newest version of ReSharper (4.1) I am getting warnings about using the var keyword and lambadas etc.. Any idea how I can disable this only for .NET 2.0 projects?

Was it helpful?

Solution

Indeed, you can use C# 3.0 compiler features when targeting .NET 2.0, except extension methods and default LINQ implementations, which are located in newer assemblies. But if you need to co-operate with VS2005 users, you can open Properties view for a given project (not Project Properties, but Edit \ Properties Window, or F4) and select desired language level.

OTHER TIPS

You can actually use var in 2.0 projects. It's syntactical sugar and the compiler works with it. Check out this for more info.

http://weblogs.asp.net/shahar/archive/2008/01/23/use-c-3-features-from-c-2-and-net-2-0-code.aspx

Daniel Moth has a great blog post on how to using C# 3.0 features (including extension methods) in .Net 2.0.

After rereading the question, this really doesn't help. You can turn off specific inspections via the R# Options window. I don't know of a way to switch back and forth between 2.0 and 3.5 project settings without manually changing them :S.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top