When I implement an interface in my class, why its implemented methods can not be private / protected / etc?
And another doubt, when I implement an interface method explicitly, why can not this method be public
?
Example:
interface IBaseInterface
{
void ExampleMethod();
}
public class BaseClass : IBaseInterface
{
public void IBaseInterface.ExampleMethod()
{
Console.WriteLine("BaseClass.ExampleMethod();");
}
}
Generate error:
Error 1 The modifier 'public' is not valid for this item