9
When I implement an interface in my class, why your implemented methods cannot be private/protected/etc?
And another question, when I implement an interface method explicitly, why can’t this method be public
?
Example:
interface IBaseInterface
{
void ExampleMethod();
}
public class BaseClass : IBaseInterface
{
public void IBaseInterface.ExampleMethod()
{
Console.WriteLine("BaseClass.ExampleMethod();");
}
}
Generates the error:
Error 1 The Modifier 'public' is not Valid for this item