Using Operators with Enumerations : enum base type « Data Type « C# / CSharp Tutorial






using System;
   
public enum FileAttributes
{
    AttrNone = 0,
    AttrReadOnly = 1,
    AttrHidden = 2,
    AttrReadyForArchive = 4
}
   
class MainClass
{
    public static void Main()
    {
        FileAttributes FileAttr;
   
        FileAttr = FileAttributes.AttrReadOnly | FileAttributes.AttrHidden;
        Console.WriteLine(FileAttr);
    }
}








2.37.enum base type
2.37.1.Convert enum to int
2.37.2.Assign int value to all elements in an enum
2.37.3.Assign int value to the first element in an enum
2.37.4.Define enumeration base types
2.37.5.Bit Flag Enums
2.37.6.Using Bit flags when declaring the enum
2.37.7.Print out string version of an enum value
2.37.8.Using a base type of long when defining an enum
2.37.9.Using Operators with Enumerations
2.37.10.enum based on byte
2.37.11.enum based on byte, and convert enum variable back to byte