int a=4; int b=5; a=a+b; // 4 + 5 = 9 b=a-b; // 9 - 5 = 4 a=a-b; // 9 - 4 = 5
//variables to swap int i = 1; int k = 2; //one-liner to swap variables (i, k) = (k, i);
static void Swap<T> (ref T a, ref T b) { T temp = a; a = b; b = temp; }