How can I load a reference to an int into an int array?

I posted this in the ‘answers’ section as well, but my questions there seem to go un-answered so I hope it’s ok to duplicate it here:

I just want to fill an array of integers with references to the original variables, so that any changes I make are also reflected in the original variables. In the example below I am copying the value of myInt into the array:

int[ ] myArray;

//this line copies the value of myInt instead of a reference:
myArray[0]=GetComponent().myInt;

In order to get a reference instead I am assuming I should use the ref keyword somewhere? I couldn’t find any examples of this…

Thanks in advance for any help!

The concepts posted in this might get you close: C#: Array of references / pointers to a number of integers - Stack Overflow

That being said, it’s probably easier to just have an array of myScript instead.

Thanks. Indeed I decided to re-write my scripts and pass around references to the script component and use .myInt when I want to affect the value. Probably a common newbie mistake :wink: