min10

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

using System;
using System.Windows.Forms;

public delegate void SampleEventHandler(string item);

public class Class1
{
    public event SampleEventHandler sampleEvent;

    public virtual void OnSampleEvent(string item)
    {
        if (sampleEvent != null)
        {
            sampleEvent(item);
        }
    }

    public static void runSampleEvent(string item)
    {
        MessageBox.Show(item);
        Console.WriteLine(item);
        Console.ReadLine();
    }

    static void Main()
    {
        Class1 class1 = new Class1();
        class1.sampleEvent += new SampleEventHandler(runSampleEvent);
        class1.OnSampleEvent("Hello world!");
    }
}

posted on 2008-10-09 14:52  min10  阅读(279)  评论(0编辑  收藏  举报