您的位置:首页 > 编程语言 > C#

C#事件的简单应用

2010-01-30 16:24 302 查看
Car.cs
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("今天天气不错噢!");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: