How to hide some members of an interface

You can implement the interface explicitly and have the implementation hidden:

public class UrClass : ICollection
{
    void ICollection.Clear() { ... }
}

The user can’t call urClassInstance.Clear() directly, but they can call ((ICollection)urClassInstance).Clear() indirectly like this.

Leave a Comment