Possible Duplicate:
Overload resolution and virtual methods
If i call this , why object method is being called?
Classes.Class2 c = new Classes.Class2();
c.GetJ(1);
public class Class1
{
public virtual void GetJ(int j)
{
}
}
class Class2:Class1
{
public override void GetJ(int j)
{
int j3 = 8;
}
public void GetJ(object j)
{
int j1 = 82;
}
}
See the C# 4.0 Specification ( https://www.microsoft.com/en-us/download/details.aspx?id=7029 )
I don’t understand that behavior, but this is in the specification, so it is correct, even if a bit disturbing (and I have a C++ background)…
Edit:
This is indeed a duplicate question (as correctly discovered by Anders Abel in his comment).
See the original Overload resolution and virtual methods for an explanation for this behavior.