Swap Two Numbers Without using Third Variable in C#

Introduction

The given below code swaps two given values of variables without using the third variable in C#.

namespace CDEMO.

{
class
Program
{

     static void Main(string[] args)

     {

           int first,second ;

           first = 1;

           second = 2;
           first = first + second;

           second = first - second;

           first = first - second;

           Console.WriteLine(first.ToString());

            Console.WriteLine(second.ToString());

            Console.ReadLine();

        }

     }

}
Ebook Download
View all
Learn
View all