Checkbox[,] checkArray = new Checkbox[2, 3]{{checkbox24,checkboxPref1,null}, {checkbox23,checkboxPref2,null}};
I am getting error . How do I initialize it?
Checkbox[,] checkArray = new Checkbox[2, 3]{{checkbox24,checkboxPref1,null}, {checkbox23,checkboxPref2,null}};
I am getting error . How do I initialize it?
OK, I think I see what's happening here. You're trying to initialize an array at a class level using this syntax, and one of the checkboxes is also a class level variable? Am I correct?
You can't do that. You can only use static variables at that point. You need to move the init code into the constructor. At the class level do this:
CheckBox[,] checkArray;
Then in your constructor:
public Form1()
{
InitializeComponent();
checkArray = new CheckBox[2, 3] { { checkbox24,checkboxPref1,null}, {checkbox23,checkboxPref2,null}};
}