static void Main(string[] args) { int n1 = 10; int n2 = 20; //使用第三方变量 int temp = n1; n1 = n2; n2 = temp; //不使用第三方变量 n1 = n1 - n2; n2 = n1 + n2; n1 = n2 - n1; Console.WriteLine("交换后N1值为{0},N2值为{1}", n1, n2); Console.ReadKey(); }