basic c# question
Posted
by CoffeeCode
on Stack Overflow
See other posts from Stack Overflow
or by CoffeeCode
Published on 2010-04-07T07:33:41Z
Indexed on
2010/04/07
7:43 UTC
Read the original article
Hit count: 314
why doesn't the element get swapped
public static void SwapArray(ref int[,] arr)
{
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr.GetLength(0); j++)
{
int temp = arr[i, j];
arr[i, j] = arr[j, i];
arr[j, i] = temp;
Console.Write(arr[i, j] + " ");
}
Console.WriteLine();
}
}
even if the parameter is without a ref modifier the array doesn't change. a copy of the reference is passed as a parameter right?
© Stack Overflow or respective owner