I am new to C# and I don't understand why compiler does not complain on this code. Here is the hierarchy of classes:
interface IAble
{
void f();
}
class AAble : IAble
{
public void f()
{
Debug.Log("---->> A - Able");
}
}
class BAble : AAble
{
public void f()
{
Debug.Log("---->> B - Able");
}
}
execution code:
IAble i = new BAble();
i.f();
On execution ---->> A - Able
was printed. Why? How the compiler knows what function should be called?
When the decision is made of what function to call - runtime or compile time? What if I defile a new class class CAble : IAble
?