Setting values to a multidimensional array from one class to another;
array not initialized?
first time posting. I'm a bit of a C# beginner and am having a bit of
trouble setting values to a multi-dimensional array. The array is held in
one class and I'm trying to set the values from another class. The problem
I can't work out is how to initialize the array variable from the other
class? In one class (GRID) I have:
public float[,] values;
then in another class i try to reference the array using a class object
(grid) like this:
GRID grid = new GRID();
this.lblFirstVal.Text = "First Value (0,0): " + grid.values[0, 0];
and I get an error on the grid.values[0,0] part of the code: Object
reference not set to an instance of an object.
Still a bit new to OO programming so I've probably not understood
something properly, but I can't for the life of me work this one out.
Thanks in advance for any help!
No comments:
Post a Comment