I have a about 20 string arrays on which I want to perform the same operation (change specific entries to another value). Therefore I have already written a method:
public static void ChangeArray<T>(ref T[,] laoArrOriginal, String lvsToChange, String lvsChangeValue)
{
int dimRow = laoArrOriginal.GetLength(0);
int dimCol = laoArrOriginal.GetLength(1);
for (int i = 0; i < dimRow; i++)
{
for (int j = 0; j < dimCol; j++)
{
if (laoArrOriginal[i, j] == lvsToChange)
{
laoArrOriginal[i, j] = lvsChangeValue;
}
}
}
}
Instead of calling 20 times this function with another array name, I thought about creating an array lcsStringArrays of my 20 arrays
String[][,] lcsStringArrays = new String[][,]{array1,array2,...}
and change them in a for loop:
for (int i = 0; i < lcsStringArrays.Length; i++ )
{
ChangeArray(ref lcsStringArrays[i], l_dblRecordCount, 1);
}
But after looping the single elements array1, array2, etc. are unaltered while the element lcsStringArrays[i] has the right content.
What I am doing wrong?
EDIT: I solved this "problem". My code in ChangeArray was wrong. I inserted the code I use now; for the case someone comes here to search for a similar solution. Thank you anyways!