// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; public class XS8 { public enum Sign { POSITIVE, NEGATIVE } public static Sign MultiplicationSign(Sign s1, Sign s2) { return (s1, s2) switch { (Sign.POSITIVE, Sign.POSITIVE) => Sign.POSITIVE, (Sign.POSITIVE, Sign.NEGATIVE) => Sign.NEGATIVE, (Sign.NEGATIVE, Sign.POSITIVE) => Sign.NEGATIVE, (Sign.NEGATIVE, Sign.NEGATIVE) => Sign.POSITIVE, (_, _) => throw new Exception("We should never end here") }; } public static void Main(string[] args) { foreach(Sign s1 in Enum.GetValues(typeof(Sign))) { foreach(Sign s2 in Enum.GetValues(typeof(Sign))) { Console.WriteLine("{0} * {1} = {2}", s1, s2, MultiplicationSign(s1, s2)); } } } }