的C#事件例子
class Receiver
{
public Receiver(Sender sender)
{
sender.Event +=new Sender.EventHandler(OnEvent);
}
private void OnEvent(object sender)
{
Console.WriteLine("Received and handled an event." );
Console.Read();
}
}
{
public Receiver(Sender sender)
{
sender.Event +=new Sender.EventHandler(OnEvent);
}
private void OnEvent(object sender)
{
Console.WriteLine("Received and handled an event." );
Console.Read();
}
}