I just got caught on interview question. I expected the output to be "Derived.Func(int)" but actual output was "Derived.Func(object)"
Why function with object argument was called and not function with int argument??
public void Main()
{
//What will be written in console output?
Derived d = new Derived();
int i = 10;
d.Func(i);
}
public class Derived : Base
{
public override void Func(int x)
{
Console.WriteLine("Derived.Func(int)");
}
public void Func(object o)
{
Console.WriteLine("Derived.Func(object)");
}
}
public class Base
{
public virtual void Func(int x)
{
Console.WriteLine("Base.Func(int)");
}
}