Exchanges two values - CSharp System

CSharp examples for System:Int32

Description

Exchanges two values

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;//from w  w  w  . jav  a  2s . c om

public class Main{
        /// <summary>
        /// Exchanges two values
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        public static void Swap(ref int a, ref int b)
        {
            int temp = a; 
            a = b; 
            b = temp; 
            return;
        }
}

Related Tutorials