// 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 enum Classic { HelloWorld, FooBar } public static class EnumPrint { public static string ToReadableString(this Classic e) { switch (e) { case Classic.HelloWorld: return "Hello world"; case Classic.FooBar: return "Foo bar"; default: throw new Exception("Unexpected enum value for Classic"); } } } public class Program { public static void Main(string[] args) { Classic e = Classic.FooBar; Console.WriteLine(e.ToReadableString()); } } }