#612 – Members of an Interface Are Implicitly Public
June 25, 2012 Leave a comment
The idea of an interface is to define a contract that a class can choose to implement. Since an interface is a public definition of a contract, it doesn’t make sense for members of an interface to be private. This means that all members in an interface are implicitly public.
public interface IDogStuff { // Implicitly public bool CanBark { get; set; } void Bark(); // Compile-time Error: The modifier 'public' is not valid for this item public void Fetch(); // Compile-time Error: The modifier 'private' is not valid for this item private void PeeOnTree(); }