If this is how client code uses the class, it doesn't really matter. If he needs to do something with a specific interface, he must declare the interface he needs and assign a class to this, for example.
I1 i = new TheClass() i.TheMethod();
Of course, using the current implementation of TheClass , it doesn't matter if i declared as I1 or I2 , since you only have one implementation.
If you need a separate implementation for each interface, you need to create explicit implementations ...
void I1.TheMethod() { Console.WriteLine("I1"); } void I2.TheMethod() { Console.WriteLine("I2"); }
But keep in mind that explicit implementations may not be publicly available. You can only implement one explicitly, and leave it as the default publicly available.
void I1.TheMethod() { Console.WriteLine("I1"); } public void TheMethod() { Console.WriteLine("Default"); }
See the msdn article for more details.
source share