扩展方法

特点

1 静态类 2 静态方法 3 第一个参数前加this

1    internal static class User
2     {
3         public static String name;
4         public static T Run<T>(this T current , T next)           
5         {
6             Console.WriteLine("Stu Run");
7             return next;
8         }
9     }

就是为this对应的类型T扩展Run方法,实例化类型T就可以调用Run方法

posted on 2019-11-28 10:43  yolanda935  阅读(125)  评论(0)    收藏  举报

导航