I have the following enum:
[Flags]
public enum Letter
{
NONE = 0,
A = 1,
B = 2,
C = 4,
A_B = A | B,
A_C = A | C,
B_C = B | C,
ALL = A | B | C
}
And I have the following piece of code:
Letter first = Letter.A_B;
Letter second = Letter.B_C;
How to get the number of flags that is in first
variable but also in second
variable?
The result I would like to have:
Letter first = Letter.A_B;
Letter second = Letter.B_C;
int numberOfSameFlags = ...; // should return 1 in this example
Letter first = Letter.A_B;
Letter second = Letter.ALL;
int numberOfSameFlags = ...; // should return 2 in this example
I tried bitwise operations but I don't think I can get this value from that.