C#中事件的继承实例分析
通常来说,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
下载地址
用户评论