I'm trying to implement an event
for logging:
In the following example, all works well:
public class BaseElement
{
internal delegate void ReportWriter(string report);
internal event ReportWriter Log;
internal void Click()
{
WebElement.Click();
Log?.Invoke("The " + Name + " is clicked");
}
}
But when I try to use Log
in the inherited class, the methods on the Log
aren't allowed to be used.
public class Button : BaseElement
{
//....
internal void Clear()
{
WebElement.Clear();
Log.//not allowed any methods
}
}
I do not want to initialize the delegate and Log
an event each time in each class - how do I use one event
for all cases?