Blank Array Causing System.NullReferenceException: 'Object reference not set to an instance of an object.'
So I have two classes:
internal class Stat
{
public int index { get; set; }
public string StatAb { get; set; }
public string L0 { get; set; }
public string L1 { get; set; }
public string L2 { get; set; }
public string L3 { get; set; }
public string L4 { get; set; }
}
internal class Num
{
public int index { get; set; }
public int StatIndex { get; set; }
public string StatG { get; set; }
public string Date { get; set; }
public string DE { get; set; }
public string Num { get; set; }
}
references:
List<Stat> stat = new List<Stat>();
List<Num>[] num = new List<Num>[45];
I'm trying to turn num into an array
this is now having an error saying numbers[0] is null (it doesn't show the fields)
num[0].Add(new Num()
{
index = Convert.ToInt32(reader[0]),
StatIndex = Convert.ToInt32(reader[1]),
StatG = reader[2].ToString(),
Date = reader[3].ToString(),
DE = reader[5].ToString(),
Num = reader[4].ToString(),
});
when I type this it seems to work (it can use the StatG when I type it)
num[5][3].StateG
, but error trying to add