Probably the easiest way to do this:
public void MyFunction(ref int[] data,int index)
{
data[index]=10;
}
And call it that way:
int[] array= { 1, 2, 3, 4, 5 };
Myfunction(ref array,2);
foreach(int num in array)
Console.WriteLine(num);
It will print 1,2,10,4,5
tommy source
share