[Flags]public enum Options : byte{None = 0,One = 1 << 0, // 1// now that value 1 is available, start shifting from thereTwo = One << 1, // 2Three = Two << 1, // 4Four = Three << 1, // 8
// same combinationsOneAndTwo = One | Two,OneTwoAndThree = One | Two | Three,}
使用LinqPad确认:
foreach(var e in Enum.GetValues(typeof(Options))) {string.Format("{0} = {1}", e.ToString(), (byte)e).Dump();}