Почему при записи в массив выходит ошибка NullReferenceException?
using System;
public class Program
{
public static void Main()
{
XXXclass xxx = new XXXclass();
string[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
int i = 0;
foreach(String car in cars){
xxx.zzz[i]=car;
i++;
}
}
}
public class XXXclass
{
public string[] zzz { get; set; }
}
Run-time exception (line 14): Object reference not set to an instance of an object.
Stack Trace:
[System.NullReferenceException: Object reference not set to an instance of an object.]
at Program.Main() :line 14