Gul Md Ershad
The implemented method would be of which interface ? There are two interfaces B and C each having the same method public m1() class A implements B and C. If class A has to implement method m1, the implemented method would be of which interface ?
By Gul Md Ershad in .NET on Nov 15 2015
  • Ravibhushan Kumar
    Oct, 2021 19

    If you give Simply give m1() implementation then it is show compile time error due to conflict . you must give implemetation as B.m1() or C.m1() then it will target B or C interface respectively.

    • 0
  • Vishwakant Tripathi
    Oct, 2021 16

    When class A will implement method m1, it will be implementing both interfaces. When we create object of A with reference of interface B, then it will be implementation of m1 of B. B objB = new A();objB.m1();If we need to implement both separately, we need to mention interface with method name like this..class A : B, C{void B.m1(){throw new NotImplementedException();}void C.m1(){throw new NotImplementedException();} }

    • 0
  • sarita rajput
    Jul, 2016 4

    Use B.m1() and C.m1()

    • 0
  • sarita rajput
    Jul, 2016 4

    Use B.m1() and C.m1()

    • 0
  • Gul Md Ershad
    Nov, 2015 15

    As long as they have the same signatures the compiler will consider them as one method. In case that one of them has a different return type it would result in compile error. Overridden method will be applicable for both the interface.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS