C# 參數參考傳遞『ref (C# 參考)』
C# 參數參考傳遞『ref (C# 參考)』
資料來源:https://msdn.microsoft.com/zh-tw/library/14akc2c7(…
Code [傳值Call by Value / 傳址Call by Reference]
class RefExample { static void Method(ref int i) { // Rest the mouse pointer over i to verify that it is an int. // The following statement would cause a compiler error if i // were boxed as an object. i = i + 44; } static void Main() { int val = 1; Method(ref val); Console.WriteLine(val); // Output: 45 } }