title: C# how to pass a list of objects to a constructor?
body: <p>I want to pass a list of objects to the constructor of a NavigationPage so that I can populate the contents of the ListView on that page.</p>
  
  <p>The objects will be different types that are all inherited from the same parent which is an abstract class called "Animal" defined as follows:</p>
  
  <pre><code>abstract class Animal { ...
  </code></pre>
  
  <p>The inherited classes are like this:</p>
  
  <pre><code>public class Horse : Animal { ...
  
  public class Cow : Animal { ...
  
  public class Dog : Animal { ...
  </code></pre>
  
  <p>The page that displays this list is a class inherited from NavigationPage as follows:</p>
  
  <pre><code>public List&lt;Animal&gt; Animals = new List&lt;Animal&gt;();
  
      public AnimalListPage(string title, List&lt;Animal&gt; animals) {
      ....
  </code></pre>
  
  <p>and I create the AnimalListPage object as follows:</p>
  
  <pre><code>var horses = new List&lt;Horse&gt;() {
      new Horse("Silver", 65, 70),
      new Horse("Tucker", 60, 68)
  };
  horsesListPage = new AnimalListPage("Horses", horses);
  ....
  </code></pre>
  
  <p><em>EDIT: in response to some of the suggestions; To clarify: I need to preserve the object type of "Horse", "Cow", "Dog", etc. in the list because each Animal type has unique attributes to be displayed. Also, each instance of Animal List will only ever have one type, i.e. there will never be a list that combines Horses, Cows, and Dogs.</em></p>
  
  <p>But I get the error:</p>
  
  <p><code>Error  CS1503  Argument 2: cannot convert from System.Collections.Generic.List&lt;AnimalTracker.Horse&gt; to System.Collections.Generic.List&lt;AnimalTracker.Animal&gt;</code></p>
  
  <p>Do I have to "cast" the "Horse" List to type "Animal" somehow? Or make the "AnimalListPage()" constructor less type specific? How do I do that?</p>
  
  <p><em>Note: I'm developing using Xamarin (though I don't think that is relevant to this issue).</em></p>