Array of Arrays or other dynamic way of handling 25 arrays

I didn’t think that I will post again so soon here!
But sadly I didn’t find much on topic and once again I think that only experts here could give me a hand. I’m asking for a bit of guide on solving this issue !

Let me try to explain what I’m trying to achieve !

I have 25 int arrays that hold 25 elements in them (each).
Each array is holding information about cities on map scene.

Once player clicks on city, GUI pops up and shows all information from Array that is responsible for that city.

Players can also trade with that city (buying or selling) but they can only sell 1 unit or 10 units, same goes for buying.

Now I need to program all this.
I have an gameObject named “Informations” that holds “CityInformation” script.
That script defines arrays and handles values on new game, loading or saving.

Each city has “Cityclickinfo” script attached to it.
This script accesses CityInformation script and pulls array informations.

I’m capable of writing line by line for each array like this :

// If player clicks sell button for this product
ArrayCityName[1] -= 10;
// if player clicks sell button for this other product
ArrayCityName[2] -= 10;

// If player clicks buy for apples 
ArrayCityName[5] += 10;

ArrayCityName[24] += 1;

//... Then write code for another city, covering every button for each array and so on and so on. 

But this would leave me with thousands of lines of code! And since I’m doing same thing for each array I want to do it in one stroke, dynamically !

What I was thinking is to have one variable that identifies city and then according to that value write code that would be universal for each array.

Something like this :

var CityID ;

// Player clicks "sell10" on city with ID1 

Array1[1] += 10;
Array1[2] += 10; 

// Player clicks "sell 10" on city with ID2

Array2[1] +=10;

Except that I wouldn’t write it like that, for each array, but rather have that “Array1” and “Array2” field depending on the CityID and then using one stroke of codes for each array.

I’m asking for guide here as in - what do I have of options?

I wanted to make an Array consisting of my 25 arrays, and then use index as ID, but that didn’t go well.

I’m using JS. Do keep in mind that I’m accessing those arrays from another script using

var info : CityInformation;

// Example of usage
Debug.Log (info.Tronskar[0]);

Any guide towards handling this is greatly appreciated, it wont help me just now but I will try to shorten similar code in future for every problem I run into ! I’m really curious about it generally !

Thanks !

// What I checked so far :

You can create an array of arrays which allows you to have jagged size arrays (arrays of the differing lengths) or a multidimensional array (as you’ve got 25 arrays each of 25 elements that would probably be in your favour) though tbh I think you’d be better off accessing an array of classes.

Anyway you can declare a multidimensional array by using commas in the nested array initialiser. (The number of commas represent the number of dimensions - 1. So a 2D (Two Dimensional array will have one comma and look something like TheArray[,]). You can then use the first of the elements in the array as the city and then the second as the product.

TheArray[1,3] will allow you to access city one product three, etc… Just store the city ID of each city as the its index with the array and the same for the products. If you use a class instead you may find it easier to code and read at a later date and will also allow you to name the products and do many over awesome things too!