C# 4 and CLR Compatibility

2019-07-21 22:31发布

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?

标签: c# .net clr
3条回答
我想做一个坏孩纸
2楼-- · 2019-07-21 22:42

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.

查看更多
聊天终结者
3楼-- · 2019-07-21 22:50

C# 4 will require the .NET 4.0 CLR.

查看更多
虎瘦雄心在
4楼-- · 2019-07-21 22:53

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

查看更多
登录 后发表回答