// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public struct VT { public int v; public VT(int v) { this.v = v; } } public class RT { public int v; public RT(int v) { this.v = v; } } public class MainClass { public static void VTBV(VT v1, VT v2) { v1.v++; v2.v++; VT tmp = v1; v1 = v2; v2 = tmp; } public static void VTBR(ref VT v1, ref VT v2) { v1.v++; v2.v++; VT tmp = v1; v1 = v2; v2 = tmp; } public static void RTBV(RT v1, RT v2) { v1.v++; v2.v++; RT tmp = v1; v1 = v2; v2 = tmp; } public static void RTBR(ref RT v1, ref RT v2) { v1.v++; v2.v++; RT tmp = v1; v1 = v2; v2 = tmp; } public static void Main(string[] args) { VT a = new VT(1); VT b = new VT(2); VTBV(a, b); Console.WriteLine(a.v + " " + b.v); VT c = new VT(1); VT d = new VT(2); VTBR(ref c, ref d); Console.WriteLine(c.v + " " + d.v); RT e = new RT(1); RT f = new RT(2); RTBV(e, f); Console.WriteLine(e.v + " " + f.v); RT g = new RT(1); RT h = new RT(2); RTBR(ref g, ref h); Console.WriteLine(g.v + " " + h.v); } } }