Are all the additions to C# for version 4 (dynamic, code contracts etc) expected to run on the current .NET CLR, or is there a planned .NET upgrade as well?
3 Answers
C# 4 will require the .NET 4.0 CLR.

- 961
- 5
- 11
-
1I must admit, I'm not 100% convinced by such a sweeping statement... certainly .NET 4.0 will, but have you tried any of the non-dynamic C# 4.0 things on the VS2010 CTP? Unfortunately I don't have my CTP available at the moment... – Marc Gravell Dec 03 '08 at 08:16
-
1The compiler in VS RC1 compiles "dynamic" and named/optional arguments when I target 3.5. – Dan Apr 02 '10 at 19:01
Well, .NET 4.0 will require CLR 4.0; however, it is a little harder to answer what parts of C# 4.0 will work on .NET 2.0/3.x. We can hope that VS2010 will still be multi-targeting(I don't have the CTP "on me" so to speak, so I can't check...). But some of the language features don't seem hugely tied to the runtime (named parameters, some of the COM changes such as "ref") - so I can't think of a good reason why they wouldn't be available when talking to .NET 2.0/3.x. I haven't checked, though.
However, as with C# 3.0, some of the features are tied to the runtime - in particular dynamic
.
I need to dig out the CTP and have another play, methinks...

- 1,026,079
- 266
- 2,566
- 2,900
-
I agree, I can see why dynamic may need a clr update, but code contracts not so much – johnc Dec 03 '08 at 05:19
-
Well, code-contracts will require the attributes themselves... and if they are housed in .NET 4.0 (which I suspect they are), you will probably need to target CLR 4.0. – Marc Gravell Dec 03 '08 at 05:30
-
Although there's a version of code contracts running against .NET 3.5, of course... – Jon Skeet Dec 03 '08 at 06:50
You don't have to wait for 4.0 to use Code Contracts as it runs on .NET 3.5, the download link for the academic preview release is here.

- 5,980
- 6
- 36
- 41
-
-
Keep the license issues aside, it doesn't need 4.0 runtime to run, that's important and nice. – Edwin Jarvis Dec 03 '08 at 03:26
-
Wow, that's awesome. I'm been dying to try it out, but I haven't had time to setup a VS 2010 box. – Jonathan Allen Dec 03 '08 at 07:31