C# 列舉型別的位元旗標
C# 的列舉型別加上 [Flags] 屬性後,就可以做位元運算,真是太神奇了
[Flags] enum Days2 { None = 0x0, Sunday = 0x1, Monday = 0x2, Tuesday = 0x4, Wednesday = 0x8, Thursday = 0x10, Friday = 0x20, Saturday = 0x40 } class MyClass { Days2 meetingDays = Days2.Tuesday | Days2.Thursday; }
參考:列舉型別 (C# 程式設計手冊)
留言