c#变量交换

 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();
        }
原文地址:https://www.cnblogs.com/huangxuQaQ/p/10731559.html