C#有扩展属性? [英] Does C# have extension properties?
本文介绍了C#有扩展属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
C#是否有扩展属性?
Does C# have extension properties?
例如,我可以一个扩展属性添加到的DateTimeFormatInfo
名为 ShortDateLongTimeFormat
这将返回 ShortDatePattern ++ LongTimePattern
?
For example, can I add an extension property to DateTimeFormatInfo
called ShortDateLongTimeFormat
which would return ShortDatePattern + " " + LongTimePattern
?
推荐答案
没有他们不存在在C#3.0,并不会在4.0中加入。它的功能要针对C#,因此它可能在未来某个日期被添加就行了。
No they do not exist in C# 3.0 and will not be added in 4.0. It's on the list of feature wants for C# so it may be added at a future date.
在这一点上,你能做的最好是的getXXX式的扩展方法。
At this point the best you can do is GetXXX style extension methods.
这篇关于C#有扩展属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文