Swap two numbers without using 3rd variable in c#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Swapp_two_number_without_3rd_var
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int a;
            int b;
            a = 1;
            b = 2;
            MessageBox.Show("Original numbers are" + a + ":"+ + b);
            a = a + b;
            b = a - b;
            a = a - b;
            MessageBox.Show("Swapping numbers are" + a + ":" + +b);
        }
    }
}

Ebook Download
View all
Learn
View all