CSharp examples for Custom Type:Enum
Add enum type as member field
using static System.Console; using System;//from w w w . java 2 s . co m class Program { static void Main(string[] args) { var p2 = new Person { Name = "Back", DateOfBirth = new DateTime(1998, 3, 17) }; WriteLine($"{p2.Name} was born on {p2.DateOfBirth:d MMM yy}"); p2.MyLevel = Level.C; WriteLine($"{p2.Name}'s favourite wonder is {p2.MyLevel}"); } } public class Person : object { // fields public string Name; public DateTime DateOfBirth; public Level MyLevel; } [System.Flags] public enum Level : byte { None = 0, A = 1, B = 1 << 1, // i.e. 2 C = 1 << 2, // i.e. 4 D = 1 << 3, // i.e. 8 E = 1 << 4, // i.e. 16 F = 1 << 5, // i.e. 32 G = 1 << 6, // i.e. 64 }