1. 首页
  2. 数据库
  3. 其它
  4. C#中事件的继承实例分析

C#中事件的继承实例分析

上传者: 2021-01-03 23:45:44上传 PDF文件 30.72KB 热度 8次
通常来说,C#中的子类无法调用父类的事件,但是可以通过在父类中创建一个方法来调用父类的事件,而子类通过调用父类的方法来触发事件。 具体实现代码如下: class parent { protected string name; public event Handle OnEvent; protected SendEvent(HandleArgs args) { if (OnEvent != null) { OnEvent(this, args); } } } class clild : parent { public clild() { name = se
下载地址
用户评论