I need help with this code which doesn't work...
I want to change items from Array1, itemps position depending on Array2 items, where Array1 = Array0 and Array0 values are always changing.
Here is what I tried:
float[] Array0 = {1.524,2.345,3.12,4.55,5.345};
float[] Array1 = Array0;
int[] Array2 = {2,1,3};
foreach (int item in Array2)
if(item!=0)
Array1[item]=0;
Output :
Array1 = {1.524,0,0,0,5.345}
Do you have any solution ?
float[] Array1 = Array2you get a pointer to the same array in memory. So there is just 1 array with 2 pointers to it. Looks like you wantArray1to be a copy ofArray0. Tryfloat[] Array1 = Array0.ToArray();float[] Array1 = (float[])Array0.Clone();myself.