Get data from Multi Object/Value ArrayList [SOLVED]
by Aaron Scovel · in Torque X 2D · 09/13/2010 (10:26 am) · 5 replies
Hey everyone! I am stuck on a little problem with Arrays, I have added a debug screen shot so you guys can see what I'm talking about.

Now that I have setup the Array, I am trying to get the vector2 value from it.
Something like this? Vector2 _position = _options[0][1]; ? (1'st row, 2nd column).
Sorry for the noob question :-) Its a little over my 1st month in C#

Now that I have setup the Array, I am trying to get the vector2 value from it.
Something like this? Vector2 _position = _options[0][1]; ? (1'st row, 2nd column).
Sorry for the noob question :-) Its a little over my 1st month in C#
About the author
Previously a PHP/MySQL Programmer/Web Developer of 10 years. In Aug 2010 I decided to change careers, and this is were I landed! I also parent 3 kids full time. TopNotched.com
#2
09/13/2010 (4:15 pm)
I get a build error if I try doing this.Quote:'object' does not contain a definition for 'newPosition' and no extension method 'newPosition' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)Obviously it looks like I need to define newPosition, but I don't know how to do this since its part of the array.
#3
09/13/2010 (4:36 pm)
I can do the following and it seems to define newPosition as a vector2Vector2 _position = ((OptionRow)_options[0]).newPosition;Now I get a new Build Error
Quote:'StarterGame2D.OptionRow.newPosition' is inaccessible due to its protection level
class OptionRow
{
int newOption;
Vector2 newPosition;
public OptionRow(int o, Vector2 p)
{
newOption = o;
newPosition = p;
}
}Do I need to change something in the OptionRow class?
#4
09/13/2010 (5:18 pm)
yeah, make the value's in the class public. That should allow you to access things from outside the class. That would go for any class which you are using only as a "data structure", any variables you want to access need to be made public, and the default is that they are set to private.
#5
09/13/2010 (5:41 pm)
Wow! Thanks guys! It works now :-)
Associate Phillip O'Shea
Violent Tulip
From the looks of your screenshot, if you wanted the position that you added, you would do this: