GregJ7
Member
- Joined
- Nov 23, 2024
- Messages
- 20
- Programming Experience
- 10+
Can someone tell me what is wrong with this code? I don't see what the error message (for the last statement) is referring to. The only object reference in that statement looks like it is dereferenced with [0,0] to an instance of the object to me.
ERROR 'Object reference not set to an instance of an object.'
Thanks.
ERROR 'Object reference not set to an instance of an object.'
C#:
public GridAttrs[,]? MyGrid;
public class GridAttrs
{
public enum E_Choices : byte { First, Second, Third };
public E_Choices selection;
}
private void Window_Loaded(Object sender, RoutedEventArgs e)
{
MyGrid = new GridAttrs[30, 30];
MyGrid[0,0].selection = GridAttrs.E_Choices.Second; // ERROR 'Object reference not set to an instance of an object.'
}
Thanks.