Computer Science, asked by abhijithr7306, 10 months ago

What is Method Overriding in C# ? Explain with an example.

Answers

Answered by pintu2345
0

overriding is a feature that allows us to have a same function

Answered by omegads04
0

Method overriding in C # is a feature like the virtual function in C++ . Method overriding is a feature that allows you to invoke functions that have the same signature that belong to different classes in the same hierarchy of inheritance using the base class reference .

class BC

{

 public void Display()

 {

    System.Console. Write Line( " BC: : Display " ) ;

 }

}

class DC : BC

{

 new public void Display()

 {

    System. Console. Write Line("DC : : Display");

 }

}

class Demo

{

 public static void Main()

 {

    BC b;

    b = new BC();

    b.Display();    

 }

}

Similar questions