.Net 2.0中使用扩展方法
生活随笔
收集整理的這篇文章主要介紹了
.Net 2.0中使用扩展方法
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
大家都知道擴展方法是不能直接在2.0中使用的
需要引用一個?System.Core的dll
不過現(xiàn)在有更加簡單的方法了
只要在工程項目中加入以下代碼就OK啦
?namespace?System.Runtime.CompilerServices
{
????[AttributeUsage(AttributeTargets.Method?|?AttributeTargets.Class?|?AttributeTargets.Assembly)]
????public?sealed?class?ExtensionAttribute?:?Attribute?{?}
}
簡直太贊了
需要引用一個?System.Core的dll
不過現(xiàn)在有更加簡單的方法了
只要在工程項目中加入以下代碼就OK啦
?namespace?System.Runtime.CompilerServices
{
????[AttributeUsage(AttributeTargets.Method?|?AttributeTargets.Class?|?AttributeTargets.Assembly)]
????public?sealed?class?ExtensionAttribute?:?Attribute?{?}
}
簡直太贊了
轉(zhuǎn)載于:https://www.cnblogs.com/51net/archive/2013/01/24/2874861.html
總結(jié)
以上是生活随笔為你收集整理的.Net 2.0中使用扩展方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux7 配置mysql5.7字符集
- 下一篇: WPF LibraryBar去背景色