So, I have searched all over stackoverflow and can't seem to find just the right answer to my question.
My question is, will equality comparison between a child object and a parent object ever return false when they point to the same memory location, and if so why? Meaning, am I soley comparing a single pointer? Or is there more going on in the background? This is related to the question "How does the compiler "see" the type of the object, and differentiate between the parent and the child (while still equating their pointers)?"
I was trying to understand this by looking at the references here and here.
Code example,
ChildType childTypeObject = new ChildType();
ParentType parentTypeObject = childTypeObject as ParentType;
if (parentTypeObject == childTypeObject)
{
// Will this always get executed?
}
EDIT:
(This is assuming the child class has not overloaded the == operator. So, if you like, use the ReferenceEquals() comparison instead.)