O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Flags Enumerations

Flags enumerations are ideal when you need enumerations with elements that can be combined with one another. As discussed earlier, it is quite possible that a contact in your database is a friend as well as a business colleague. The .NET Framework has a great way of supporting such situations.

When defining a Flags enumeration you need to keep three things in mind.

  1. You should define an enumeration name for the situation of “none of the combinations” (for example, by using None). This item has a value of 0.

  2. You need to assign values that can be combined bitwise. To do that, you count the individual values up by using powers of two.

  3. You add the Flags attribute to the enumeration.

The classic example is the button order and question ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required