title: C# base class as parameter type
body: <p>I have two classes as follows, and Class A inherits from Class B.</p>
  
  <pre><code>public class A
  {
       public string Title { get; set; }
  }
  
  public class B: A
  {
  
  }
  </code></pre>
  
  <p>Then I have a function as follows which takes in a list of items of class A:</p>
  
  <pre><code>public static void Get(List&lt;A&gt; values)
  {
      // Do something
  }
  </code></pre>
  
  <p>Now when I try to pass a list of items of Class B, into the function as follows,</p>
  
  <pre><code>private function void Test()
  {
       var k = new List&lt;B&gt;();
       Get(k);
  }
  </code></pre>
  
  <p>I get the following error message</p>
  
  <blockquote>
    <p>cannot convert from 'System.Collections.Generic.List&lt;B>' to 'System.Collections.Generic.List&lt;A>'</p>
  </blockquote>
  
  <p>Should this not work as B just inherits from A and will have the properties that A has?</p>
  
  <p>I have already spent hours trying to look this up, but I have not been to figure out what I an doing wrong. How can I fix it?</p>