Interview Question
Qus: What is Method Hiding in C#?
If the child class don’t want to use methods from the base class, child class can implement its own version of the same method with same signature. For example, in the classes below, Pipedrive () is implemented in the child class with same signature. This can be called as Method Hiding.
class Car
{
public void TypeOfDrive()
{
Console.WriteLine("Right Hand Drive");
}
}
class Ford : Car
{
public void TypeOfDrive()
{
Console.WriteLine("Right Hand ");
}
}
Answers (2)
class Car
{
public void TypeOfDrive()
{
Console.WriteLine("Right Hand Drive");
}
}
class Ford : Car
{
public void TypeOfDrive()
{
Console.WriteLine("Right Hand ");
}
}