public static void Main() { myclass s = new myclass(); int x = 10, y = 20; s.swap(ref x, ref y); Console.WriteLine("x = {0}, y = {1}", x, y); }
public static void Main() { string str1 = "犬", str2 = "猫"; myclass s = new myclass(); s.swap(str1, str2); Console.WriteLine("Main:str1 = {0}, str2 = {1}", str1, str2); }
static void Main(string[] args) { unsafe { int x = 10; int y = 20; int * t1 = &x; int * t2 = &y; myclass m1 = new myclass(); m1.swap(t1, t2); Console.WriteLine("Main"); Console.WriteLine("x: " + x); Console.WriteLine("y: " + y); Console.ReadLine(); } }