title: C#: Generic members in non-generic types?
body: <p>I have a custom control which contains a list of objects.  The control is instantiated by the visual designer and then configured in code.  The control is a grid which displays a list of entities.</p>
  
  <p>I have an initialise method like this.</p>
  
  <pre><code>public void Initialise(ISession session, Type type, ICollection&lt;IPersistentObject&gt; objs)
  </code></pre>
  
  <p>IPersistentObject is an interface.  However this doesn't work when I want to assign a collection of something that implements IPersistentObject.</p>
  
  <p>So I changed it to this.</p>
  
  <pre><code>public void Initialise&lt;T&gt;(ISession session, Type type, ICollection&lt;T&gt; objs) where T : class, IPersistentObject
  </code></pre>
  
  <p>But now I want to assign the objs parameter to a member variable of type <code>ICollection&lt;IPersistentObject&gt;</code> which doesn't work.</p>
  
  <p>I can't make the class generic because it is a control which can't have generic types AFAIK.  I can't copy the collection because the control MUST modify the passed in collection, not take a copy and modify that.</p>
  
  <p>What should I do?</p>