#2:Enum With Flags

Enum can take Flags as attribute and perform bit operations over the numerics(Values must be power of two).

[Flags]
public enum Color
{
Red=1,-->0001
Yellow=2,--->0010
Green=4--->0100
}

var combination = Color.Red | Color.Green;
Console.WriteLine(combination); /* Red,Green*/

They are helpful when you need to hold multiple values/Combination  of values defined in an Enum.

Leave a comment