public class Car
{
public event EventHandler<EventArgs> Exploded;
public void show()
{
Exploded(this,EventArgs.Empty);
}
}
public class CarEventArgs : EventArgs
{
}
Program.cs
static void Main(string[] args)
{
Car myCar = new Car();
myCar.Exploded += new EventHandler<EventArgs>(myCar_Exploded);
myCar.show();
Console.Read();
}
static void myCar_Exploded(object sender, EventArgs e)
{
MessageBox.Show("今天天气不错噢!");
}