I currently have a project I'm working on that has a target of .NET Framework 3.5. I am using Visual Studio 2010; however my coworkers use Visual Studio 2008. I am able to use C# 4.0 features such as optional function parameters, but if they try to build the same code with the same target, they are unable to. It was my understanding that even though I was using Visual Studio 2010 I would not be able to use .NET 4.0 features since the target was .NET 3.5.
+7
A:
By default the multi-targeting framework only restricts the set of features that would cause compatibility issues with the CLR (not source code). Hence named and optional is legal because there is no issue using it on the 2.0 or 3.5 CLR.
If you want to restrict the set of C# features to those legal on the 3.5 compiler you need to change the language version option.
- Right click on project and select properties
- Go to build tab
- Click the Advanced button
- Switch the Language Version combo to "C# 3.0"
JaredPar
2010-10-25 21:04:01