码迷,mamicode.com
首页 > Windows程序 > 详细

c#中的委托使用(方法的调用, 和类的实话)

时间:2015-02-09 00:46:13      阅读:272      评论:0      收藏:0      [点我收藏+]

标签:

方法的调用
    delegate int test1(int a);
    class Program
    {
       
     
        static int num = 10;
        static void Main(string[] args)
        {
            test1 t = new test1(max);
            t(40);
            Console.WriteLine("max,{0}", num);
            Console.ReadLine();
        }
        public static int max(int a)
        {
            num += a;
            return num;
        }
    }
类额实例化

    class  weituo {
        public   int num = 10;
        //非静态
        public  int max(int a)
        {
            num += a;
            return num;
        }
        
    }

Main ()
{
     weituo wt = new weituo();
            test1 t1 = new test1(wt.max);
            t1(50);
} 

 

c#中的委托使用(方法的调用, 和类的实话)

标签:

原文地址:http://www.cnblogs.com/codemouserman/p/4280681.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!