Skip to content

Instantly share code, notes, and snippets.

@dchw
Created April 12, 2014 07:16
Show Gist options
  • Save dchw/10522737 to your computer and use it in GitHub Desktop.
Save dchw/10522737 to your computer and use it in GitHub Desktop.
Using left shit to achieve a continuous range of values, while still using bit fields appropriately.
[Flags]
public enum Powers : byte
{
Speed = 1,
Looks = 1 << 1,
Money = 1 << 2,
Smart = 1 << 3,
None = 1 << 4
}
public enum Superhero
{
Superman,
Batman,
Aquaman,
IronMan
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment