Qus:    What is Method Hiding in C#?
Nov 30, 2020 19:38 DotNet 2 Answers Views: 1037 SAI

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 ");

}

}

Prev Next
Answers (2)
PARTH Dec 01, 2020 14:10
Answer:   Method Hiding means to hide the methods of the base class from derived class. It is also known as Method Shadowing. In method hiding, you can hide the implementation of the methods of a base class from the derived class using the new keyword.

DIVYA Dec 01, 2020 15:11
Answer:   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 ");
}
}

Post Your Answer
Guest User

Not sure what solution is right for you?

Choose the right one for you.
Get the help of the experts and find a solution that best suits your needs.


Let`s Connect