0
why ref is used, can i omit it?
static void Swap<T>(ref T a, ref T b) { T temp = a; a = b; b = temp; }
2 ответов
+ 3
You can't omit the ref keyword, because the swap function is call by reference.(manipulate in address of original value) If omit the ref key word, the method is call by value, value only swap in the function. You can go back the <method> course and review the concept.
+ 2
if you omit it, when you will call your function, no change will happen