class Test { public static void Main() { int a = 3; DoWork(a); Console.WriteLine("The value of a is " + a); } public static void DoWork(int i) { i++; } }The program will result in : The value of a is 3
class Test { public static void Main() { int a = 3; // must be initialized DoWork(ref a); // note ref Console.WriteLine("The value of a is " + a); } public static void DoWork(ref int i) // note ref { i++; } }The program will result : The value of a is 4
class Test { public static void Main() { int a; // may be left un-initialized DoWork(out a); // note out Console.WriteLine("The value of a is " + a); } public static void DoWork(out int i) // note out { i=4; } }The program will result : The value of a is 4