S
Sharon
Hello gurus,
I have an abstract class:
public abstract class MyBase
{
public delegate void EventAdded(Int32 EventID);
public event EventAdded OnEventAdded;
}
And a derived class:
public class MyDerived : MyBase
{
Public void Func()
{
int n = 0;
if( OnEventAdded != null )
{
OnEventAdded(n);
}
}
}
And the compiler throw the error:
Error 1 The event MyDerived.OnEventAdded' can only appear on the left hand
side of += or -=
It seems the derived class can use the base class event only as += or -= and
ca not fire it.
Am I correct?
Why is that?
How can use the event at the derived class to fire it?
I have an abstract class:
public abstract class MyBase
{
public delegate void EventAdded(Int32 EventID);
public event EventAdded OnEventAdded;
}
And a derived class:
public class MyDerived : MyBase
{
Public void Func()
{
int n = 0;
if( OnEventAdded != null )
{
OnEventAdded(n);
}
}
}
And the compiler throw the error:
Error 1 The event MyDerived.OnEventAdded' can only appear on the left hand
side of += or -=
It seems the derived class can use the base class event only as += or -= and
ca not fire it.
Am I correct?
Why is that?
How can use the event at the derived class to fire it?