I believe this is also a design issue. Is it possible to override a method from the interface when the redefinition signature has a different type of signature?
For example, let's say that I need two different classes, which should have the following:
interface IProtocolClient
{
void connect(Type1 t1, Type2 t2, Type3 t3);
}
Is it possible to implement an interface, but you have a different set of parameters?
class A : IProtocolClient {
public void connect( Type1 t1, Type2 t2, Type3 t3 ) {}
}
class B : IProtocolClient {
public void connect( Type1 t1, Type2 t2, Type3 t3, Type4 t4 ) {}
}
Or should I approach this by creating a base class instead, and then create a wrapper method in class B, for example:
class B : IProtocolClient {
public void connect( Type1 t1, Type2 t2, Type3 t3, Type4 t4)
{
connect(t1,t2,t3);
}
public void connect( Type1 t1, Type2 t2, Type3 t3) {}
}
source
share