title: How can c# share the generic implementations of reference types when 'typeof' and 'is' are used?
body: <p>As far as I understand, at runtime the CLR implementation creates different machine code (or whatever runtime representation) for the same generic Type with different parameterized valuetypes, but shares the machine code for reference types. This makes sense since reference types are going to take up the same size (the size of a reference). </p>
  
  <p>What I don't understand is how this can work with code that explicitly uses code which depends on the type of T directly through something like typeof(T) or is T. For example, in the class:</p>
  
  <pre><code>class TestClass&lt;T&gt; 
  {
      public static bool TestAType(Object pObj) { return pObj is T; }
  }
  </code></pre>
  
  <p>I don't see how the same implementation for T = List and T = String can allow <code>TestClass&lt;String&gt;.TestAType("hello")</code> to be true and <code>TestClass&lt;List&lt;int&gt;&gt;.TestAType("hello")</code> to be false.</p>
  
  <p>I'm making the assumption here that the machine code is the same for the compiled generic types, which could of course be false.  </p>