What is Method Hiding?
Method hiding, in short, is the crippled, mentally-ill brother of method overriding. For example, look at the next code:
class A
{
public string GetName()
{
return "A";
}
}
class B : A
{
public new string GetName()
{
return "B";
}
}
Class A has a GetName method; class B inherits from class A and implements the GetName method as well.
Look carefully at the GetName method signature in class B – do you see the new keyword there? this means that the method doesn’t override the implementation in class A, it just hides it. What does that mean? read on.
So What’s the Big Deal? Hide, Override… Who Cares?
Read more: IronShay
QR: