Example
using System; namespace Samples { public class FlagsAttributeSample { [Flags] enum DayOfWeek {Sunday = 0x1, Monday = 0x2, Tuesday = 0x4, Wednesday = 0x8, Thursday = 0x10, Friday = 0x20, Saturday = 0x40}; public static void Main() { DayOfWeek weekDays = DayOfWeek.Monday | DayOfWeek.Tuesday | DayOfWeek.Wednesday | DayOfWeek.Thursday | DayOfWeek.Friday; Console.WriteLine("Week days: {0}", weekDays); DayOfWeek weekendDays = DayOfWeek.Sunday | DayOfWeek.Saturday; Console.WriteLine("Weekend days: {0}", weekendDays); } } }
Week days: Monday, Tuesday, Wednesday, Thursday, Friday Weekend days: Sunday, Saturday
Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.