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("今天天气不错噢!");
}
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("今天天气不错噢!");
}
相关文章推荐
- C# 委托与事件简单应用
- C# 委托与事件简单应用
- 委托与事件的简单应用(不同控件之间的控制及参数传递,C# VB)
- c#中的委托和事件的简单实例_c#应用
- 【Asp.Net】C#事件简单应用
- Java设计模式之观察者模式的应用--简单的事件通知工具
- C#实践—简单的事件设计
- C#2.0谓词的简单应用
- C# .Net 中序列化和反序列化的简单应用
- [C#应用]得到组件事件的委托列表
- c#学习笔记之九 事件(event)的使用,一个简单的例子揭示其设计理念
- 分享一个C#自定义事件的实际应用
- C#开发一个简单的P2P应用
- [C#应用]得到组件事件的委托列表
- unity 委托事件简单应用
- c#编译 --csc命令的简单应用
- c#实现虚拟光驱--应用层(简单涉及驱动部分)
- C#中委托和事件在观察者模式中的应用实例
- java图像界面开发简单实例-JButton及事件的简单应用
- .net(c#)随机数的最简单应用