Synopsis: | Use the [Flags] attribute on an enum if a bitwise operation is to be performed on the numeric values |
Language: | C# |
Severity Level: | 7 |
Category: | Data types |
Description: |
It is good practice to use the Example:
The printed result will beFileInfo file = new FileInfo(fileName); file.Attributes = FileAttributes.Hidden | FileAttributes.ReadOnly; Console.WriteLine("file.Attributes = {0}", file.Attributes.ToString()); ReadOnly|Hidden .
Use an Example:
[Flags] public enum AccessPrivileges { Read = 0x1, Write = 0x2, Append = 0x4, Delete = 0x8, All = Read | Write | Append | Delete } |