static void Main(string[] args) { internalexamples. int x = 4; f1(x); Console.WriteLine(x); f2(ref x); Console.WriteLine(x); PassTest t = new PassTest(x); Console.WriteLine(string.Join(",", t.vals.ToArray())); f3(t); Console.WriteLine(string.Join(",", t.vals.ToArray())); f4(ref t); Console.WriteLine(string.Join(",", t.vals.ToArray())); }
static void Main(string[] args) { // Different examples of function calls int x = 4; f1(x); Console.WriteLine(x); f2(ref x); Console.WriteLine(x); PassTest t = new PassTest(x); Console.WriteLine(string.Join(",", t.vals.ToArray())); f3(t); Console.WriteLine(string.Join(",", t.vals.ToArray())); f4(ref t); Console.WriteLine(string.Join(",", t.vals.ToArray())); }
static void f4(ref PassTest t) { t = new PassTest(5); t.vals.Add(10); }
static void f3(PassTest t) { t.vals.Add(5); }