Here is the IL for your first case:
Code:
.method public hidebysig instance void Me() cil managed
{
// Code size 7 (0x7)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call void [mscorlib]System.Console::WriteLine(object)
IL_0006: ret
} // end of method Parent::Me
The overlaod of the WriteLine method that takes an object as a parameter is called. The ToString method of the object type (Child) is called to return a string representation of the object. Keyword âthisâ refers to an instance of the Child class, which simply inherits (and invokes) a member implementation defined in its base class, Parent. It is not the case that an object of type Parent is invoking the Me method.
Here is the IL for your second case:
Code:
.method public hidebysig instance void Me() cil managed
{
// Code size 12 (0xc)
.maxstack 1
IL_0000: ldarg.0
IL_0001: call instance string [mscorlib]System.Object::ToString()
IL_0006: call void [mscorlib]System.Console::WriteLine(string)
IL_000b: ret
} // end of method Parent::Me
Here the Child class calls its base classâs implementation of the ToString method (as indicated by keyword 'base'). However, the parameterless ToString method is defined in System.Object (the Parent classâs direct base class). So the Child class is ultimately using System.Objects implementation of ToString which simply returns a string representation of the object, hence Child.
Child inherits the member implementations defined in the Parent class. When those implementations are invoked in your code, however, they are invoked by an object of type Child, not an object of type Parent.
Anyway, that's my story, and I'm sticking to it...for now...
HTH,
Bob