c# - Is flags attribute necessary? -


i found or without flags attributes, can bit operation if defined following enum

enum testtype {     none = 0x0,     type1 = 0x1,     type2 = 0x2 } 

i wondering why need flags attribute?

c# treat them same either way, c# isn't consumer:

  • propertygrid render differently allow combinations
  • xmlserializer accept / reject delimited combinations based on flag
  • enum.parse likewise (from string), , enum's .tostring() behave differently
  • lots of other code displays or processes value treat them differently

more importantly, though, expression of intent other developers (and code); this meant treated combinations, not exclusive values.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -