Suppose the following code without the ref keyword, which obviously does not replace the passed variable, because it is passed as a value.
class ProgramInt { public static void Test(int i)
Now, to make this function work as expected, you could add the ref keyword as usual:
class ProgramIntRef { public static void Test(ref int i)
Now I'm puzzled by why array members are passed implicitly by reference when passing to functions. Are array value types?
class ProgramIntArray { public static void Test(int[] ia)
arrays parameter-passing pass-by-reference pass-by-value c #
Lazlo
source share