正在阅读:C#事件机制归纳(上)C#事件机制归纳(上)

2004-07-16 10:16 出处:CSDN 作者:changqi 责任编辑:linjixiong

 


using System;


class Class1

{

       static void Main(string[] args)

       {

               Student s1=new Student();

               Student s2=new Student();

               s1.RegisterOK +=new Student.DelegateRegisterOkEvent(Student_RegisterOK);

               s2.RegisterOK +=new Student.DelegateRegisterOkEvent(Student_RegisterOK);

               s1.Register();

               s2.Register();

               Console.ReadLine();

       }

       static void Student_RegisterOK()

       {

              Console.WriteLine("Hello");

       }

}

class Student

{

       public delegate void DelegateRegisterOkEvent();

       public event DelegateRegisterOkEvent RegisterOK;

 


察看评论详细内容 我要发表评论
作者笔名 简短内容 发表时间
:

键盘也能翻页,试试“← →”键

关注我们

最新资讯离线随时看 聊天吐槽赢奖品