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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With