Master Morality Master Morality - 1 month ago 8
C# Question

Why implement interface explicitly?

So, what exactly is a good use case for implementing an interface explicitly?

Is it only so that people using the class don't have to look at all those methods/properties in intellisense?

Answer

If you implement two interfaces, both with the same method and different implementations, then you have to implement explicitly.

public interface IDoItFast
{
    void Go();
}
public interface IDoItSlow
{
    void Go();
}
public class JustDoIt : IDoItFast, IDoItSlow
{
    void IDoItFast.Go()
    {
    }

    void IDoItSlow.Go()
    {
    }
}