Swapping Two Numbers without using a Third Variable

 Please find the attached source code for the complete reference.
 
static void Main(string[] args)
{
      //Swap 2 numbers without a third variable
      int a = 10;
      int b = 20;            
      Console.WriteLine("Values before Swapping...");
      Console.WriteLine("a = {0} ; b={1}",a,b);
      a = a + b; 
      b = a - b;
      a = a - b;
     Console.WriteLine("Values After Swapping...");
     Console.WriteLine("a = {0} ; b={1}",a,b);
     Console.ReadLine();
}
 
In the above sample i have hard coded 2 integers with values a=10 and b=20.
 
Logic explanation
 
First step is a= a+b ; Now a holds value 30.
 
Second step: b=a-b; Now b holds value (30-20) =10;
 
Third step : a=a-b; Now a holds value (30-10) = 20;
 
Values before swapping :
a= 10;
b=20;
 
Values after swapping:
a=20;
b=10; 
 
So in three simple steps we have achieved the desired result.