首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#中event根本使用

2012-10-08 
C#中event基本使用using Systemusing System.Collections.Genericusing System.Textnamespace ConsoleD

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();                }            }        }    }}
?

热点排行