Swap
This algorithm exchanges the value of two variables.
public static void Swap(ref int a, ref int b)
{
a ^= b;
b ^= a;
a ^= b;
}
Example
int a = 1025;
int b = -5579;
Swap(ref a, ref b);
Output
a: -5579
b: 1025