I have a problem that I have two types, and the difference is just in a signiture of a method. My ‘Plan-B’ is that forget this difference and I handle it in the concrete implementation, but for ‘Plan-A’ I want the following:
public interface MyInterface
{
int property;
void MyMethod();
ICollection<int> MyMethod();
}
public interface A : MyInterface
{
void MyMethod();
}
public class AClass : A
{
public void MyMethod() { ... }
}
public interface B : MyInterface
{
ICollection<int> MyMethod();
}
public class BClass : B
{
public ICollection<int> MyMethod() { ... }
}
So I want that AClass has to be implement methods from A, and do not have to implement ICollection MyMethod from MyInterface.
I hope I wrote it clear.
Is it possible?
Thank you!
Not sure I understand precisely, but try this:
In other words, interface
Aadds the methodvoid MyMethod()to interfaceMyInterface, and interfaceBadds the methodICollection<int> MyMethod()to interfaceMyInterface.Note that you still won’t be able to call e.g.
as
MyMethod()won’t be a member ofMyInterface.