Initialize multidimensional array
5 answers
Okay, I think I can see what's going on here. Are you trying to initialize an array at the class level using this syntax and one of the checkboxes is also a class level variable? I'm right?
You cannot do this. You can only use static variables at this point. You need to move your initialization code to the constructor. At the class level, do the following:
CheckBox[,] checkArray;
Then in your constructor
public Form1()
{
InitializeComponent();
checkArray = new CheckBox[2, 3] { { checkbox24,checkboxPref1,null}, {checkbox23,checkboxPref2,null}};
}
+2
source to share