// 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 class One { public int Val { get; set; } public static One operator+(One v1, One v2) { return new One { Val = v1.Val + v2.Val }; } public override string ToString() { return Val.ToString(); } } public class Two { public int Val { get; set; } public static implicit operator One(Two v) { return new One { Val = v.Val }; } } public class Program { public static void Main(string[] args) { One a = new One { Val = 123 }; One b = new One { Val = 456 }; Console.WriteLine(a + b); Two c = new Two { Val = 456 }; Console.WriteLine(a + c); } } }