c# - Bitwise Logic knowing what was enabled from the server -
I'm following some quick codes to help with my logic on bitwise code (my first time doing this Actually I have 3 properties, each of which is 1,2,4
int A = 1 int b = 2 int c = 4 Say that A and C are checked, this will be equal to 5 and this value will be saved in the database. good.
Now the way I was tested with that value, there is a need to work on that path.
In the example, the value is 5, then how will I know with some logic qualities were examined?
That's why I'm not saying to work with you, what am I doing,
int i = A & amp; C; // If I == 5, then we knew that this A and C was examined but do you need to do this for every possibility?
Thank you in advance
You can test these situations: i & amp; a! = 0 / true if A is set in i i & amp; B! = 0 / true if B is set in I = After saying this, bitfields are inappropriate in many situations, especially when you store the resulting value in a database, usually only Some flags are better defined by more columns.
Comments
Post a Comment