Ashwani Chaudhary

Ashwani Chaudhary

  • NA
  • 179
  • 29.4k

Is this overriding of Print() Method ?

Jul 15 2015 3:25 AM
namespace ConsoleApplication13
{
using System;

public class Parent
{

string parentString;

public Parent()
{

Console.WriteLine("Parent Constructor.");

}

public void print()
{

Console.WriteLine("I'm a Parent Class.");

}

}



public class Child : Parent
{

public Child()
{

Console.WriteLine("Child Constructor.");

}

public new void print()
{
Console.WriteLine("I'm a Child Class.");
}

public static void Main()
{

Child child = new Child();
child.print();
((Parent)child).print();
Console.ReadLine();

}

}
}


Answers (3)