If you have TheMethod() in interfaces I1 and I2, and the following class
class TheClass : I1, I2
{
void TheMethod()
}
If something instantiates TheClass, how does it know which interface it is using?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If that’s how the client code is using the class, it doesn’t really matter. If it needs to do something interface specific, it should declare the interface it needs, and assign the class to that e.g.
Of course, using your current implementation
TheClass, it doesn’t matter if declarediasI1, orI2, as you only have a single implementation.If you want a separate implementation per interface, then you need to create explicit implementations …
But keep in mind, explicit implementations cannot be public. You can implement just one explicitly, and leave the other as the default which can be public.
Have a look the msdn article for more details.