class Base
{
public virtual void MethodA(int x)
{
Console.WriteLine ("In Base Class");
}
}
class Derived : Base
{
public override void MethodA(int x)
{
Console.WriteLine ("In derived INT)");
}
public void MethodA(object o)
{
Console.WriteLine ("In derived OBJECT");
}
}
class Test
{
static void Main()
{
Derived d = new Derived();
int k = 20;
d.MethodA(k);
}
}
The output I got for this is "In derived OBJECT". What is the reason for this strange behaviour? After some research, I found out the reason is the signatures declared in the base class are ignored. Why are they ignored?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…