C#的扩展方法真的非常简单好用:相关链接:http://www.cnblogs.com/suger/archive/2012/05/13/2498248.html
使用例子如下:
譬如说我要在String这个类中添加一个我自己的方法
申明静态类,然后静态方法,注意第一个参数必须家this关键字
public static class Extension
{
public static string appendStringName(this String s, String name)
{
return s+name;
}
}
调用
Console.WriteLine("123".appendStringName("333"));