static void Main(string[] args) { RefPoint rp = new RefPoint(2, 2); ValPoint vp = new ValPoint(2, 2); f_byval(rp); g_byval(vp); Console.WriteLine("Reference Type By Value: " + rp.Y); Console.WriteLine("Value Type By Value: " + vp.Y); f_byref(ref rp); g_byref(ref vp); Console.WriteLine("Reference Type By Ref: " + rp.Y); Console.WriteLine("Value Type By Ref: " + vp.Y); }
static void g_byref(ref ValPoint vp) { vp.Y = 4444; }
static void g_byval(ValPoint vp) { vp.Y = 1234; }