title: Type cannot be used as type parameter 'T' in the generic type or method - Why?
body: <p>I'm trying inherit two different Models from a Interface. These Models should be passed either as List or Collection to a Method. Now I'm getting this error message:</p>
  
  <pre><code>The type 'InheritanceTest.FooModel' cannot be used as type parameter 'T' in the generic type or method 'InheritanceTest.Service.DoSomethingWith&lt;T&gt;(System.Collections.Generic.IEnumerable&lt;T&gt;)'. There is no implicit reference conversion from 'InheritanceTest.FooModel' to 'InheritanceTest.IModel&lt;InheritanceTest.IModelItem&gt;'. C:\Work\InheritanceTest\InheritanceTest\Program.cs 14 13 InheritanceTest
  </code></pre>
  
  <p>Can somebody please explain me, what I'm doing wrong? :D</p>
  
  <p>Demo Code:</p>
  
  <pre><code>interface IModel&lt;T&gt; where T : IModelItem
  {
      string Name { get; set; }
  
      IEnumerable&lt;T&gt; Items { get; set; }
  }
  
  interface IModelItem
  {
      string Name { get; set; }
  }
  
  class FooModel : IModel&lt;FooModelItem&gt;
  {
      public FooModel()
      {
          Items = new List&lt;FooModelItem&gt;();
      }
  
      public string Name { get; set; }
      public IEnumerable&lt;FooModelItem&gt; Items { get; set; }
  }
  
  class FooModelItem : IModelItem
  {
      public string Name { get; set; }
  }
  
  class Program
  {
      static void Main(string[] args)
      {
          var fooLists = new List&lt;FooModel&gt;();
          var barLists = new ObservableCollection&lt;BarModel&gt;();
  
          var service = new Service();
  
          service.DoSomethingWith(fooLists);
          service.DoSomethingWith(barLists);
      }
  }
  
  class Service
  {
      public void DoSomethingWith&lt;T&gt;(IEnumerable&lt;T&gt; list) where T : IModel&lt;IModelItem&gt;
      {
          foreach (var model in list)
          {
              Debug.WriteLine(model.Name);
  
              foreach (var item in model.Items)
              {
                  Debug.WriteLine(item.Name);
              }
          }
      }
  }
  </code></pre>
  
  <p>The Demo Project can be found at GitHub:
  <a href="https://github.com/SunboX/InheritanceTest/blob/master/InheritanceTest/Program.cs" rel="noreferrer">https://github.com/SunboX/InheritanceTest/blob/master/InheritanceTest/Program.cs</a></p>