2
Answers

Access Parent class method using child class object

srinath

srinath

13y
1.3k
1
 Hi,

  I have a scenario as given below.

  Class A
  {
    public void method()
   {
     Console.WriteLine("A");
   }
  }

  Class B :A
  {
    public void method()
   {
     Console.WriteLine("B");
   }
  }

  Here in main method of a class, I create an object for Class B and I want to access method() of Class A.
  i.e B b = new B(); Using this 'b' object I want to access the method() of Class A.
  I am unable to do this please give me the solution

Answers (2)