Skip to content

Instantly share code, notes, and snippets.

@arphox
Last active November 22, 2021 06:22
Show Gist options
  • Save arphox/d43d7a1a309f36f65bad2f8c73d9f5c9 to your computer and use it in GitHub Desktop.
Save arphox/d43d7a1a309f36f65bad2f8c73d9f5c9 to your computer and use it in GitHub Desktop.
Enum.HasFlag implementation
[System.Security.SecuritySafeCritical]
public Boolean HasFlag(Enum flag) {
if (flag == null)
throw new ArgumentNullException("flag");
Contract.EndContractBlock();
if (!this.GetType().IsEquivalentTo(flag.GetType())) {
throw new ArgumentException(Environment.GetResourceString("Argument_EnumTypeDoesNotMatch", flag.GetType(), this.GetType()));
}
return InternalHasFlag(flag);
}
@arphox
Copy link
Author

arphox commented May 15, 2019

Shared on Medium, don't delete!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment