IsSet
I did not write this I just found it very useful, check http://stackoverflow.com/questions/7244 for original post.
Source
public static bool IsSet(this Enum input, Enum matchTo)
{
return (Convert.ToUInt32(input) & Convert.ToUInt32(matchTo)) != 0;
}
Example
MyEnum tester = MyEnum.FlagA | MyEnum.FlagB;
if(tester.IsSet(MyEnum.FlagA))
©2007-2025 ExtensionMethod.NET.
ExtensionMethod.NET was built by Loek van den Ouweland and Fons Sonnemans
with ASP.NET Core, HTML, CSS, Javascript, SQL Server and some of the great methods you have posted here.
By using this website, you agree to the legal stuff .
We thank all who contributed to this website for the last twelve years. It really helped making this website a success!
Looking for Visual Studio Code Snippets? Visit our sister site VisualStudioCodeSnippets.com .