What is Method Overriding in C# ? Explain with an example.
Answers
Answered by
0
overriding is a feature that allows us to have a same function
Answered by
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
Geography,
7 months ago
Physics,
7 months ago
Social Sciences,
1 year ago
Math,
1 year ago
Math,
1 year ago