读书人

C#中event根本使用

发布时间: 2012-10-08 19:54:56 作者: rapoo

C#中event基本使用

using System;using System.Collections.Generic;using System.Text;namespace ConsoleDemo{    class Program    {        static void Main(string[] args)        {            SendCls sc = new SendCls();            sc.eveMyeve += new SendCls.deleMydele(sc_eveMyeve);            sc.run();        }        static void sc_eveMyeve()        {            Console.WriteLine("事件已响应");            Console.ReadKey();        }    }    class SendCls    {        public delegate void deleMydele(); //声明一个无参数返回值为空的代理        public event deleMydele eveMyeve;  //声明该代理类型的事件,         public void run()        {            for (int i = 0; i < 99999;i++ )            {                if (i==99990)                {                    eveMyeve();                }            }        }    }}
?

读书人网 >C#

热点推荐