Example #1
0
        public static void Run()
        {
            int a = 10;
            //调用委托形式一
            IntMethodInvoker showIntMethod = new IntMethodInvoker(ShowInt);

            showIntMethod(a);

            //调用委托形式二
            TwoLongsOp showSumMethod = ShowSum;
            double     sum           = showSumMethod.Invoke(1.23, 2.33);

            Console.WriteLine("两数之和:" + sum);

            GetString showString = a.ToString;
            string    str        = showString();

            Console.WriteLine("使用委托调用a.ToString()方法:" + str);
        }
Example #2
0
 private void _2(IntMethodInvoker imi, int x)
 {
     imi(x);
 }