// 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; public class Vector3D { private int x; private int y; private int z; public Vector3D(int x, int y, int z) { this.x = x; this.y = y; this.z = z; } public override string ToString() { return ("[" + x + "," + y + "," + z + "]"); } public static Vector3D operator+(Vector3D v1, Vector3D v2) { return new Vector3D(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); } public static Vector3D operator-(Vector3D v1, Vector3D v2) { return new Vector3D(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); } } class MainClass { public static void Main(string[] args) { Vector3D a = new Vector3D(1, 2, 3); Vector3D b = new Vector3D(1, 2, 4); Console.WriteLine(a + " + " + b + " = " + (a + b)); Console.WriteLine(a + " - " + b + " = " + (a - b)); } }