What does really happen when you do GetType()?
<p>As we know, C# objects have a pointer to their type, so when you call <code>GetType()</code> it checks that pointer and returns the real type of an object. But if I do this:</p>

<pre><code>A objA = new A();
object obj = (object)objA;
if (obj.GetType() == typeof(object)) ; // this is true
</code></pre>

<p>But what happens here <code>object obj = (object)objA;</code>? Does it create some sort of reference object, that references <code>objA</code>, but has a type pointer to <code>object</code>, or is it a completely new object, that just happens to be pointing to the same properties, fields, etc. as <code>objA</code>? Certainly, you can access both objects now and they will have a different type, but point to the same data. How does that work?</p>

<p>The other question is: is GetType() guaranteed to return the actual type of an object? For instance, say there is a method with signature <code>void Method(object sender)</code> and we pass object of type <code>A</code> as a parameter. Will <code>sender.GetType()</code> return type <code>A</code>, or <code>object</code>? And Why?</p>

<p>Other tricky thing is that you can do <code>(A)obj</code> and it will work. How does CLR now that <code>obj</code> was once of type <code>A</code>?</p>

<p>Would be glad if someone could break it down a bit clearer than "C# via CLR" does.</p>

<p><strong>Update.</strong> My bad, should have run the code before posting the question. So, if <code>GetType()</code> really always returns the real type, than all other questions become clear too.</p>
