title: Cast object to a generic type
body: <p>I haven't slept in a while so this is probably easier than I think it is.</p>
  
  <p>I have a generic class that's more or less this:</p>
  
  <pre><code>public class Reference&lt;T&gt; where T : APIResource //&lt;- APIResource is abstract btw
  {
      private T _value = null;
      public T value
      { 
          get { return _value; }
      }
  }
  </code></pre>
  
  <p>Elsewhere, in a custom serialize method, someone is passing in an <code>object</code> that is actually an instance of <code>Reference&lt;(something)&gt;</code>. I simply want to skip to the "value" property that every <code>Reference&lt;&gt;</code> object has, so I want to go:</p>
  
  <pre><code>string serialize(object o)
  {
      return base.serialize( ((Reference&lt;&gt;) o).value );
  }
  </code></pre>
  
  <p>Of course, life isn't that simple because as the compiler puts it:</p>
  
  <p><code>using the generic type "Reference&lt;T&gt;" requires 1 type arguments</code></p>
  
  <p>How can I do what I want to do?</p>