Last post May 09, 2019 03:37 PM by wavemaster
May 08, 2019 09:25 PM|wavemaster|LINK
I need to loop through a dataset where each member has a bit location value (say for this example I need to inspect locations 2, 7, 9).
If that bit location is set (in the bitmask) I need to do something.
Is there a spiffy way to do this, without converting the bitmask to a string?
May 08, 2019 10:15 PM|mgebhard|LINK
May 09, 2019 03:37 PM|wavemaster|LINK
Yes, bitwise AND i.e. "&".
Ended up using enums set at the values of the positions I was interested in:
enum3 = 4
enum7 = 128
enum9 = 512
if ((bitmask & (int)SupplyMask.enum7) == (int)SupplyMask.enum7)
Spiffy and readable.