Why can't I use the same generic type with inherited interface?
<p>HI,
I have the following scenario which I will try to explain as best as I can, appologies in advance if this is a silly question.
I have two interfaces ( for the purposes of this example have nothing in them)</p>

<pre><code>public interface interfaceA {}
public interface interfaceB: interfaceA {}
</code></pre>

<p>And 2 classes </p>

<pre><code>public classA&lt;interfaceA&gt; {}
public classB: classA&lt;interfaceB&gt; { }
</code></pre>

<p>Now also elsewhere I have a method which accepts the generic type as a param :</p>

<pre><code>public static void DoSomething( ClassA&lt;interfaceB&gt; p_val ) {}
</code></pre>

<p>Ok then i consume these classes when creating my objects.</p>

<pre><code>ClassB obj1 = new ClassB();
ClassA&lt;interfaceA&gt; obj2 = new ClassA&lt;interfaceA&gt;();
</code></pre>

<p>Ok all fine when I pass obj1 into DoSomething() now but when I try to pass obj2 into my DoSomething() method, i get a compilation error saying it cannot convert from interfaceA to interfaceB. </p>

<p>This kind of make sense since in my method, the generic param type is explicitly interfaceB. However if i want the method to accept both generic types ( obj1 and obj2), what should I do? hopefully this make sense.</p>
