#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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s