(73)C# 扩展方法
2021-03-08 04:27
                         标签:stat   ons   lin   static   静态类   nbsp   OLE   fun   code      扩展方法的要求: 1.扩展方法要求在一个静态类中 2.扩展方法本身也是静态方法 3.扩展方法第一个参数是    [this 要扩展的类 参数名称]   (73)C# 扩展方法 标签:stat   ons   lin   static   静态类   nbsp   OLE   fun   code    原文地址:https://www.cnblogs.com/buchizaodian/p/12811001.html    public class Program
    {
        static void Main()
        {
            int a = 10;
            int b=a.fun();
            Console.WriteLine(b);
        }
    }
    public static class A
    {
        public static int fun(this int num)
        {
            return num * 2;
        }
    }