title: How to assign different generic classes to same variable
body: <p>I know this question has probably been asked many times and my title probably needs some help so feel free to close this question after pointing me to a duplicate... just not sure how to properly search for the answer at the moment.</p>
  
  <p>I've got a situation where a variable may need to hold and instance of <code>ISolrOperations&lt;Class1&gt;</code> or it may need to hold an instance of <code>ISolrOperations&lt;Class2&gt;</code>. The problem is that there is no base version of the interface and so there's no class I can define the variable as (other than object, which obviously has no knowledge of <code>ISolrOperations&lt;T&gt;</code>'s methods) to be able to hold either class.</p>
  
  <p>So the only solutions I know of are either a) Do an if/else statement where I do everything I need with <code>ISolrOperations&lt;Class1&gt;</code> in one block and everything I need in <code>ISolrOperations&lt;Class2&gt;</code> in the other block even though each block will basically contain duplicate code. Or b) I could make the variable dynamic and just lose some compile time validation of my code.</p>
  
  <p>I'm trying to think if there is some way I can create a generic wrapper class that has a non-generic base. And maybe the base has to treat it as an object but uses reflection... but them I'm like screw it; if I have to go through that trouble may as well just use the dynamic keyword.</p>
  
  <p>Is there a more "proper" design pattern to handle this scenario? Or is my choice basically between dynamic or writing a lot of code just to make myself feel like I'm doing it "right" when dynamic is really the most practical solution?</p>
  
  <p>Edit: Actually I'm not sure if dynamic would solve this problem :/</p>
  
  <p>Edit 2: Nope... other code uses lambdas with the variable which requires casting it which I obviously don't know what to cast to at compile time so that won't work.</p>