4
Reply

Multiple Interfaces with same Method

kalit sikka

kalit sikka

15y
5.8k
0
Reply

    1. interface G1 {
    2. // method declaration
    3. void mymethod();
    4. }
    5. interface G2 {
    6. // method declaration
    7. void mymethod();
    8. }
    9. // Geeks implements both
    10. // G1 and G2 interface
    11. class Geeks : G1, G2
    12. {
    13. // Here mymethod belongs to
    14. // G1 interface
    15. void G1.mymethod()
    16. {
    17. Console.WriteLine("GeeksforGeeks");
    18. }
    19. // Here mymethod belongs to
    20. // G2 interface
    21. void G2.mymethod()
    22. {
    23. Console.WriteLine("GeeksforGeeks");
    24. }
    25. }

     To show what happens to the possible conflicts if you 
     implement multiple interfaces: there are no conflicts.


     If multiple interfaces have the exact same method, you
     merely have to implement it.


     If multiple interfaces have similar methods, you must
     implement them all.There's still no conflict.

    Hi ,

    Same Method in Both the Interface u just Impliment the One Interface that it.ok i will give with examples later.ok bye

     

    We have two Interface A and B both have one method common in them i.e. GetCustomer(), Suppose if Class C will implement both the interfaces than what will be the implications of Common Method on it.