If we implement multipole interface in the same class with conflict method name so we don’t need to define all or in other words we can say if we have conflict methods in same class so we can’t implement their body independently in the same class coz of same name and same signature so we have to use interface name before method name to remove this method confiscation let’s see an example:
- interface testInterface1 {
- void Show();
- }
- interface testInterface2 {
- void Show();
- }
- class Abc: testInterface1,
- testInterface2 {
- void testInterface1.Show() {
- Console.WriteLine("For testInterface1 !!");
- }
- void testInterface2.Show() {
- Console.WriteLine("For testInterface2 !!");
- }
- }
- class Program {
- static void Main(string[] args) {
- testInterface1 obj1 = new Abc();
- testInterface1 obj2 = new Abc();
- obj1.Show();
- obj2.Show();
- Console.ReadLine();
- }
- }
No comments:
Post a Comment