Yes we can. We have to explicitly implement the interfaces in such cases. We can do that by using interface name and it's method name in the class..Interface I1{void m(); }Interface I2{void m(); }Class A : I1, I2 {public void I1.m(){ }public void I2.m(){ } }
interface A { void Hello(); } interface B { void Hello(); } class Test : A, B { public void Hello() { Console.WriteLine("Hello to all"); } } public class interfacetest { public static void Main() { Test Obj1 = new Test(); Obj1.Hello(); } }
Yes.IT Will be possible by using explicit interface name with method name
Yes Possible can use explicit implementation.
by the explicitly interface implementation
Yes, by implementing the concept of explicit implementation of the interface where we specify InterfaceName.MethodName to avoid ambiguity.
yes, use explicit implementation of interfaces
Yes. It is called Explicit Interface Implementation.
yes you can implement method by name of interface first
We have use the "Explicit Interface implementation" feature of C# to achieve this. For example // Declare the English units interface: interface IEnglishDimensions {float Length();float Width(); } // Declare the metric units interface: interface IMetricDimensions {float Length();float Width(); } //You can implement in the class like below class Box : IEnglishDimensions, IMetricDimensions {float lengthInches;float widthInches;public Box(float length, float width) {lengthInches = length;widthInches = width;} // Explicitly implement the members of IEnglishDimensions:float IEnglishDimensions.Length() {return lengthInches;}float IEnglishDimensions.Width() {return widthInches; } // Explicitly implement the members of IMetricDimensions:float IMetricDimensions.Length() {return lengthInches * 2.54f;}float IMetricDimensions.Width() {return widthInches * 2.54f;} }Warning : An interface member that is explicitly implemented cannot be accessed from a class instance: You have to cast it to interface type to call the method.Check this MSDN link for the full example :https://msdn.microsoft.com/en-us/library/aa288461(v=vs.71).aspx