How to cast a generic parameter?
<p>Here's what I am trying to write:</p>

<pre><code>public void Foo&lt;T&gt;(T parameter) {
  otherObject.Bar&lt;T&gt;(parameter);
}
</code></pre>

<p>The signature of the Bar() method is:</p>

<pre><code>public void Bar&lt;T&gt;(T parameter) where T: class 
</code></pre>

<p>So I get a compile error because the T in Foo's signature doesn't have the same constraint. Unfortunately I can't write:</p>

<pre><code>public void Foo&lt;T&gt;(T parameter) where T: class {
  otherObject.Bar&lt;T&gt;(parameter);
}
</code></pre>

<p>because Foo is implementing a method defined in an external interface.  Question is:</p>

<p>Can I somehow transpose the T within the method Foo before calling Bar.  (Note, I can be sure that T always will be a class  -  I just need to get past the compiler).</p>

<p>The only way I have found is using reflection but I wonder if there is a simpler trick I'm missing.</p>
