Hello @Smrithi Surendran ,
Welcome to Microsoft Q&A!
It is recommended that you set the enum constants to the power of 2.
You can see official document code sample it also be power of 2.
In your example the values look like this
A = 0 0000
B = 1 0001
C = 2 0010
D = 3 0011
Key = Keys.B | Keys.C;
B | C = 0011 which is 3 or D
If you choose powers of 2, you will get
A = 1 = 2^0 0001
B = 2 = 2^1 0010
C = 4 = 2^2 0100
D = 8 = 2^3 1000
You can refer to this question operator with enum values in C#
Thank you.
Junjie
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.