Skip to content

Instantly share code, notes, and snippets.

@davunderscorei
Created November 15, 2012 09:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save davunderscorei/4077627 to your computer and use it in GitHub Desktop.
booling enum arguments
public enum MyEnum { alpha, beta, gamma }
public void MyOuterFunction(bool a, bool b, bool c)
{
MyEnum asdf = MyEnum.alpha;
if(a) asdf &= ~MyEnum.alpha;
if(b) asdf |= MyEnum.beta;
if(c) asdf |= MyEnum.gamma;
MyFunction(asdf);
}
public void MyFunction(MyEnum e)
{
//stuff
}
public enum MyEnum { alpha, beta, gamma }
public void MyOuterFunction(bool a, bool b, bool c)
{
MyFunction(
alpha | //this line only if a == true
beta | //this line only if b == true
gamma);
}
public void MyFunction(MyEnum e)
{
//stuff
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment