C# 4 and CLR Compatibility

2019-07-21 22:38发布

问题:

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?

回答1:

C# 4 will require the .NET 4.0 CLR.



回答2:

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...



回答3:

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.



标签: c# .net clr