I am trying to fill a two-dimensional array with objects of my class but the debugger marks it as if it had a null value in the assignment operator line and in the line after. I've created a default constructor to prevent that from being the problem. I need it to take the value of
matrixOfButtons[i, n] = new SpecialButton(i, n);
But it won't, it will stay as null. Why is that if I am already assigning the value with another constructor in the line above?
protected override void OnNavigatedTo(NavigationEventArgs e)
{
int NumberOfRows = 15;
int NumberOfColumns = 6;
// Create array with default constructor
SpecialButton[,] matrixOfButtons = new SpecialButton[NumberOfRows, NumberOfColumns];
for (int i = 0; i < NumberOfRows; i++)
{
for(int n = 0; n < NumberOfColumns; n++)
{
matrixOfButtons[i, n] = new SpecialButton(i, n);
// THE PREVIOUS LINE AND THE ONES THAT FOLLOW DISPLAY
//A NULL VALUE FOR matrixOfButtons[i,n] IN THE DEBUGGER.
}
}
}
Constructors for SpecialButton object
public SpecialButton()
{
}
public SpecialButton(int row, int column)
{
button = new ToggleButton();
row += 1;
column += 1;
Grid.SetRow(button, row);
Grid.SetColumn(button, column);
}