CSharp examples for Custom Type:Method Parameter
In the following example, p and x refer to the same memory locations:
using System;//from w w w.ja v a 2 s . co m class Test { static void Foo (ref int p) { p = p + 1; // Increment p by 1 Console.WriteLine (p); // Write p to screen } static void Main() { int x = 8; Foo (ref x); // Ask Foo to deal directly with x Console.WriteLine (x); // x is now 9 } }