c# - Get all containing flags -


i have variable containing flags , wounder how i'm able check flags set.

my flags.

[flags]     public enum button{          //can't have more 30 flags         //if enum added or deleted need change loop in method addbutton          // exit flags         exit = 1 << 0,          cancel = 1 << 1,          abort = 1 << 2,         close = 1 << 3,          //proced flags         accept = 1 << 4,          ok = 1 << 5,         submit = 1 << 6,          //question flags         no = 1 << 7,         yes = 1 << 8,          //save , load         save = 1 << 9,         saveall = 1 << 10,         savenew = 1 << 11,         open = 1 << 12,         load = 1 << 12     } 

and here check flags

    (int = 1; <= 12; ++i) {         if((buttons & 1 << i) == 1 << i){          }     } 

apparently can't use way check flags.

to clear want know flags set in buttons.

update: can't use enum.hasflag() because making game in unity , uses mono. apparently mono hasn't support hasflag yet.

just cast buttons int. , might want make sure loop starts 0, or you'll miss 1 check.

for (int = 0; <= 12; ++i) {     if (((int)buttons & 1 << i) == 1 << i)     {      } } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -