Deepak Bisht

Deepak Bisht

  • NA
  • 23
  • 0

Inheritance for same method name

May 8 2013 1:37 AM
Hi All,
I have a doubt in below program:-

when i m calling the CallMe method from derived class instace and object it calls only the Abstract method not the interface method why so can anyone spread some light on it??

it works fine if i create object of interface and abstract and allocate memory of derived class.

interface M1
    {
         void CallMe();

    }

    public abstract class ME
    {
      public abstract void CallMe();

 
    }


    public class Derive:ME, M1
    {
        void M1.CallMe()
        {
            Console.WriteLine("I am interface method");
        }

      public override void CallMe()
        {
            Console.WriteLine("I am abstract class method");
        }


 
    }

    class Program
    {

        static void Main(string[] args)
        {
            Derive obj = new Derive();
            obj.CallMe();

            Console.ReadLine();

        }
    }


Output:  I am abstract class method


Answers (4)