could anyone give me a helping hand with class declaration in another class or just tell me, what could be wrong?
I have 2 classes:
public class alfa
{
int color = "";
public int y=0;
public int getY()
{
return y;
}
public void setColor(string x)
{
color = x;
}
}
public class beta
{
int size = 10;
public alfa[] alfaB = new alfa[size / 2];
for (int i = 0; i < size/2; i++)
{
alfaB[i].setColor("b");
alfaB[i].y = 0;
}
}
Syntax check in IDE shows no error, but there is something wrong in runtime. In class Beta Visual Studio offers me all functions of alfaB (y variable, setColor method) but in runtime I see error System.NullReferenceException: The object reference is not set to an object instance. It seems there is no access to alfa class but I have no idea why.
Any advice?