Cody P. answered 03/28/26
Tutor
New to Wyzant
Software Engineer - Fintech
I have used in C# by using the flag attribute on an enum class.
[Flags]
public enum Permissions
{
None = 0,
Read = 1 << 0, // 1
Write = 1 << 1, // 2
Execute = 1 << 2 // 4
}
below are examples of using to combine flags and also check if a flag exists.
var userPermissions = Permissions.Read | Permissions.Write;
bool canRead = (userPermissions & Permissions.Read) == Permissions.Read;