Using a bitmask in C#
问题 Let\'s say I have the following int susan = 2; //0010 int bob = 4; //0100 int karen = 8; //1000 and I pass 10 (8 + 2) as a parameter to a method and I want to decode this to mean susan and karen I know that 10 is 1010 but how can I do some logic to see if a specific bit is checked as in if (condition_for_karen) // How to quickly check whether effective karen bit is 1 Right now all i can think of is to check whether the number i passed is 14 // 1110 12 // 1100 10 // 1010 8 // 1000 When I have