Hi, all
I have some code as shown below:
public class Child : Parent
{
public event Action<string> OnEventTriggered;
}
public class Parent
{
protected virtual void OnEventTriggered( double x ) { }
}
The compiler shows warning message:
'Child.OnEventTriggered' hides inherited member 'Parent.OnEventTriggered(double)'. Use the new keyword if hiding was intended.
Virtual method shares the same name with that of event.
Param type of the virtual method is double, and Action is string type.
Why does it violate the checking rule?
Thanks for answering in advance.
Additional scenario:
If I change the code to this, it doesn't show any warning.
What's the difference between these code?
public class Child : Parent
{
public void OnEventTriggered( string x ) { }
}
public class Parent
{
protected virtual void OnEventTriggered( double x ) { }
}