title: Initialize an array of a class in a constructor
body: <p>I have a class <code>Garage</code> that has a property which is an array of type <code>Car</code>, which is another class in the program. I've tried several iterations and get run-time errors on most of them. I get a <code>NullRefernceException</code> whenever I try to run it. This happens in the <code>Program</code> class where I try to access the length property of the <code>CarLot</code> array.  </p>
  
  <p>I know this has something to do with the <code>CarLot</code> property of the <code>Garage</code> class being an array instead of just <code>Car</code>. What piece am I missing here so that the array isn't set to null when the program tries to use it?</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          Garage g = new Garage();
          //this is where the exception occurs
          g.CarLot[0] = new Car(5, "car model");
          Console.ReadLine();
      }
  }
  
  public class Garage 
  {
      public Car[] CarLot { get; set; }
      public Garage() { }
      //this should be able to be 0 or greater
      public Garage(params Car[] c)
      {
          Car[] cars = { };
          CarLot = cars;
      }
  }
  
  public class Car
  {
      public int VIN { get; set; }
      public int Year { get; set; }
      public string Model { get; set; }
      public Car(int _vin, string _model)
      {
          _vin = VIN;
          _model = Model;
      }
      public Car() { }
      public void Print()
      {
          Console.WriteLine("Here is some information about the car {0} and {1} ");
      }
  }
  </code></pre>