title: Returning array of objects from static function
body: <p>I am making a <em>basic</em> Visual Studio project.
  Easiest way to explain is to show the code.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  
  namespace testing
  {
      class Program
      {
          static void Main(string[] args)
          {
  
              int amountOfCars = getAmountOfCars();
              Car[] myCars = createCars(amountOfCars);
  
          }
  
          public static int getAmountOfCars (){
              Console.WriteLine("Amount of Cars to enter");
              int amountOfCars = Convert.ToInt32(Console.ReadLine());
              return amountOfCars;
          }
  
  
          public static Car createCars(int amountOfCars)
  
          {
              Car[] myCars = new Car[amountOfCars];
              for (int i = 0; i &lt; amountOfCars; i++)
              {
                  Console.WriteLine("Enter brand");
                  string brand = Convert.ToString(Console.ReadLine());
  
                  Console.WriteLine("Enter amount of wheels");
                  int amountOfWheels = Convert.ToInt32(Console.ReadLine());
  
                  Console.WriteLine("Enter amount of seats");
                  int amountOfSeats = Convert.ToInt32(Console.ReadLine());
  
                  myCars[i] = new Car(brand, amountOfWheels, amountOfSeats);
              }
              return myCars[amountOfCars];
  
          }
      }
  }
  
  </code></pre>
  
  <p>This line </p>
  
  <pre><code> Car[] myCars = createCars(amountOfCars);
  </code></pre>
  
  <p>Throws the following error:</p>
  
  <blockquote>
    <p>Cannot implicitly convert type testing.Car to testing.Car[]</p>
  </blockquote>
  
  <p>So, I then tried this to convert over </p>
  
  <pre><code> Car[] myCars = (Car[]) createCars(amountOfCars);
  </code></pre>
  
  <p>But it still throws the error.</p>
  
  <p>Essentially I am just trying to return the <code>array</code> of <code>objects</code> from <code>createcar</code> function, so that it can be used within the rest of the code. </p>
  
  <p>What is the best practice to solve this?</p>