title: Return an ObservableCollection depending on enum value
body: <p>My C# application defines the following enumeration:</p>
  
  <pre><code>public enum ItemTypes {
    REQUIREMENTS,
    TEST_CASES
  }
  </code></pre>
  
  <p>Now I would like to define an interface which gets all items matching one of the <code>ItemTypes</code> and returns them as an <code>ObservableCollection</code>. As I don't know what enum value is passed I thought using a generic <code>T</code> would be the way to go. However the following does not work as <code>T</code> is not recognized:</p>
  
  <pre><code>interface IDataSourceService {
    ObservableCollection&lt;T&gt; GetItems(Enums.ItemTypes itemType);
  }
  </code></pre>
  
  <p>The implementing class shall look something like this (more or less pseudo-code):</p>
  
  <pre><code>ObservableCollection&lt;T&gt; GetItems(Enums.ItemTypes itemType) {
    // Define an ObservableCollection which could hold "anything".
    ObservableCollection&lt;T&gt; result = null;
    switch (itemType) {
      case Enums.ItemTypes.REQUIREMENTS:
        // Get all requirements from the data source
        ObservableCollection&lt;CRequirement&gt; result = new ObservableCollection&lt;CRequirement&gt;();
        result = foo();
        break;
  
      case Enums.ItemTypes.TEST_CASES:
        // Get all test cases from the data source
        ObservableCollection&lt;CTestCase&gt; result = new ObservableCollection&lt;CTestCase&gt;();
        result = bar();
        break;
    }      
    return result;
  }
  </code></pre>