I have and interface as shown below:
public delegate void ScriptFinished();
public interface IScript
{
event ScriptFinished ScriptFinishedEvent;
}
Now I want to implement the interface as shown below:
public class Script : IScript
{
event ScriptFinished ScriptFinishedEvent;
}
But I get error:
'Script.ScriptFinishedEvent' cannot implement an interface member because it is not public.
Ok, I add public to the event:
public interface IScript
{
public event ScriptFinished ScriptFinishedEvent;
}
But the error is:
The modifier 'public' is not valid for this item
What I do wrong here and how can I implement an interface with events?
Change:
public class Script : IScript
{
event ScriptFinished ScriptFinishedEvent;
}
to:
public class Script : IScript
{
public event ScriptFinished ScriptFinishedEvent;
}
'Script.ScriptFinishedEvent' cannot implement an interface member because it is not public.
is referring to the class, not the interface.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With