title: Generic classes with methods that work only for some type parameters
body: <p>Say that you're writing a library to display things on the screen, so you create an <code>IDisplayable</code> interface. This interface has one method to create a control from the object: <code>displayable.GetControl()</code>.</p>
  
  <p>You want to create your own list type that can be displayed: <code>MyList&lt;T&gt;</code>. Now this list can only be displayed if <code>T</code> is an <code>IDisplayable</code>, so you could ask in the MyList class that T should implement IDisplayable. But you also want to use this list type in some places when T is not IDisplayable (and as a result this list will not be displayable). So is it possible to say that MyList implements IDisplayable if T implements IDisplayable? I would also be happy if <code>MyList&lt;T&gt;</code> always implements IDisplayable but throws an exception at runtime if you try to call <code>GetControl()</code> if T is not IDisplayable, but I'd like to know if there's a statically type-safe way to do it. Can this be done? Or am I looking at the wrong solution?</p>
  
  <p>Edit:</p>
  
  <p>I agree with the suggestions so far that MyList may have too many responsibilities. My original idea was to create a <code>MyDisplayableList&lt;T&gt; : MyList&lt;T&gt; (where T : IDisplayable)</code>.</p>
  
  <p>The problem with this approach is that I have a lot of methods that take a MyList and return a MyList (for example methods like Select in Linq). So if I use select on an MyDisplayableList I get back a MyList and them I'm unable to display it even though it is a MyList...is there a type safe way to handle this problem in C#?</p>