0

I am trying to deal with a bit mask:

Mask |= 1 << MapID;

anybody can explain how it works? Thanks for help guys

  • 3
    Check [this](http://stackoverflow.com/questions/3261451/using-a-bitmask-in-c-sharp) – Gilad Green Aug 25 '16 at 09:42
  • 1
    If you want to understand what that line does exactly, refer to the MSDN operators explanations: [OR assignment](https://msdn.microsoft.com/en-us/library/h5f1zzaw.aspx) and [Bitwise left-shift](https://msdn.microsoft.com/en-us/library/a1sway8w.aspx) – Keyur PATEL Aug 25 '16 at 09:55
  • A byte is hex like 0xAB so you mask is doing a OR function 0xAB | 0x01. You code has |= which is equivalent to Mask = Mask | 1. You are shifting the mask by MapID so if MapID = 4, then 0x01 << 4 = 0x10 – jdweng Aug 25 '16 at 09:57

0 Answers0