Interface reimplementation
-
Suppose ...
public interface IMyInterface{ void MyMethod(); } public class ClassA:IMyInterface{ public void MyMethod(){} } public class ClassB:ClassA,IMyInterface{ public void MyMethod(){} }
Can anyone tell me if it's required to specify that ClassB inherits IMyInterface ? The interface is to my opinion inherited through the base class ClassA, but it seems specifying (or not) the interface inheritance in the derived class ClassB makes no difference. -
Suppose ...
public interface IMyInterface{ void MyMethod(); } public class ClassA:IMyInterface{ public void MyMethod(){} } public class ClassB:ClassA,IMyInterface{ public void MyMethod(){} }
Can anyone tell me if it's required to specify that ClassB inherits IMyInterface ? The interface is to my opinion inherited through the base class ClassA, but it seems specifying (or not) the interface inheritance in the derived class ClassB makes no difference.You dont need to unless u want to 'override' the behaviour. This normally means you have designed something wrong :) To override the interface implementation, you would likely have to use an explicit implementation.
**
xacc.ide-0.2.0.77 - now with C# 3.5 support and Navigation Bar!^
New xacc.ide release RSS feed^**
-
You dont need to unless u want to 'override' the behaviour. This normally means you have designed something wrong :) To override the interface implementation, you would likely have to use an explicit implementation.
**
xacc.ide-0.2.0.77 - now with C# 3.5 support and Navigation Bar!^
New xacc.ide release RSS feed^**
Indeed I want to override (reimplement) the interface behaviour in the derived ClassB, but my question really is wether to use ...
public class ClassB:ClassA,IMyInterface
orpublic class ClassB:ClassA
as the ClassB declaration ? Both work for me, but I was wondering if there's a difference (behind the scenes ?) for either one of them !