I'm trying to initialize an array of objects with predetermined values but I get "Object reference not set to an instance of an object".
I don't understand the cause of the problem since I'm initializing properly and then I'm adding values to the array.
The main is:
Sorteo P=new Sorteo();
P.Predetermined();
Class Sorteo:
// Atribute
private ClassA[] A;
int count=0;
// Methods
public Sorteo()
{
A=new ClassA[2];
}
public void Add(ClassA a)
{
A[count]=a;
count++;
}
public void PredeterminedValues()
{
A[0].Add(new ClassB("SomeString1"));
A[1].Add(new ClassB("SomeString2"));
}