相关疑难解决方法(0)

C#:提升继承的事件

我有一个包含以下事件的基类:

public event EventHandler Loading;
public event EventHandler Finished;
Run Code Online (Sandbox Code Playgroud)

在继承自此基类的类中,我尝试引发事件:

this.Loading(this, new EventHandler()); // All we care about is which object is loading.
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

事件'BaseClass.Loading'只能出现在+ =或 - =(BaseClass')的左侧

我假设我不能像其他继承的成员一样访问这些事件?

c# events inheritance

139
推荐指数
3
解决办法
6万
查看次数

标签 统计

c# ×1

events ×1

inheritance ×1