0

I would like to manually change a value of a public variable inside an object that's stored in a multidimensional array. The array is stored in aList<T>

Something like this:

areaList[0].array[90, 50].type = 1;

The code above doesn't work.

The code below works, but doesn't fill the purpose, since I just want to change one variable of a single object stored in the array.

foreach (Area[,] area in areaList]
{
area[90, 50].type = 1;
}

[EDIT] I found out that I could initialize a reference of the object like this:

Area[,] green = areaList[0];
green[90, 50].type = 1;

And thus being able to change the variable-values of the object that's inside the list.

1 Answer 1

1

use arrayList.get(position) .

areaList.get(0).array[90,50].type=1;
Sign up to request clarification or add additional context in comments.

1 Comment

Doesn't work 'System.Collections.ArrayList' does not contain a definition for 'get' and no extension method 'get'. When i try areaList(0).array[90, 50].type=1, it doesn't work either.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.