新酷功能的C#4.0 [英] New Cool Features of C# 4.0

查看:211
本文介绍了新酷功能的C#4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是你们正在寻找最酷的新功能,或者说,你听说过被释放在C#4.0。

解决方案

动态的东西听起来很酷,如果你需要它的,但我不希望经常使用它的

为代表和接口的通用差异是类似 - 缺少变化是很头疼的时刻,但很多地方是一个痛苦将不包括在C#4中可用的有限变化的地方。

在COM功能并不特别关心我 - 我真的应该得到更多的把手上它们是什么,虽然

建立稳定的类型时,可选和命名的参数可以使一个很大的区别:它使语法如下:

 者P =新的Person(名称:夫君,年龄:32);
 

而不必构造函数重载的庞大组合。我想preFER为只读自动实现的属性的形式编写不变类型多一点支持,但我不认为我们会得到这些。 (他们当然不是目前所提出的功能列表中)。

我个人其实更感兴趣的是一对夫妇的框架的的.NET 4.0的特性 - 尤其是<一个href="http://blogs.msdn.com/bclteam/archive/2008/11/11/introduction-to-$c$c-contracts-melitta-andersen.aspx"相对=nofollow> code合同和并行扩展的。

What are the coolest new features that you guys are looking for, or that you've heard are releasing in c# 4.0.

解决方案

The dynamic stuff sounds cool if you need it but I don't expect to use it very often.

The generic variance for delegates and interfaces is similar - the lack of variance is a headache at the moment, but many of the places where it's a pain won't be covered by the limited variance available in C# 4.

The COM features don't particularly interest me - I really ought to get more of a handle on what they are though.

Optional and named parameters could make a big difference when building immutable types: it enables syntax like:

Person p = new Person (name: "Jon", age: 32);

without having mammoth combinations of constructor overloads. I'd prefer a bit more support for writing immutable types in the form of readonly automatically implemented properties, but I don't expect we'll get those. (They certainly aren't in the proposed feature list at the moment.)

I'm personally actually more interested in a couple of the framework features of .NET 4.0 - in particular code contracts and parallel extensions.

这篇关于新酷功能的C#4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆