title: C#: Generic List Property
body: <p>I am doing a UserControl where anyone can plugin a List.</p>
  
  <p>Internally that List is sorted and programmatically added are the items to a internal ItemaSource.</p>
  
  <p>Anyone who wants to use this UserControl must use the  Property <code>ElementsDataSource</code></p>
  
  <pre><code>public List&lt;T&gt; ElementsDataSource {get;set;}
  </code></pre>
  
  <p><code>List&lt;T&gt;</code> is not working/compiling, instead I have to use <code>List&lt;object&gt;</code>.</p>
  
  <p>But then I have to cast the objects inside the ElementsDataSource again to the generic type when I sort them internally and reuse them etc...</p>
  
  <p>How can I offer a generic List Property to my user just like .NET is doing it?</p>
  
  <p>Maybe my user is plugin in a <code>List&lt;Customer&gt;</code> or <code>List&lt;Department&gt;</code> etc... or am I totally wrong and should use <code>List&lt;Object&gt;</code> ?</p>