Skip to content

Instantly share code, notes, and snippets.

@SBajonczak
Created December 28, 2021 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SBajonczak/827ce5914477b6063e9b8465a1cc891a to your computer and use it in GitHub Desktop.
Save SBajonczak/827ce5914477b6063e9b8465a1cc891a to your computer and use it in GitHub Desktop.
Generate Bitmask Check
public bool HasAccessTo(int profileValue, ApplicationRole roleToCheck){
return (profileValue & roleToCheck) === roleToCheck
}
// Will result true
bool result= HasAccesTo(21,ApplicationRole.Contributor);
// Will result false
bool result= HasAccesTo(21,ApplicationRole.Administrator);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment