.net - Combining Enums -


is there way combine enums in vb.net?

i believe want flag type enum.

you need add flags attribute top of enum, , can combine enums 'or' keyword.

like this:

<flags()> _ enum combinationenums integer   hasbutton = 1   titlebar = 2   readonly = 4   etc = 8 end enum 

note: numbers right twice big (powers of 2) - needed able separate individual flags have been set.

combine desired flags using or keyword:

dim settings combinationenums settings = combinationenums.titlebar or combinationenums.readonly 

this sets titlebar , readonly enum

to check what's been set:

if (settings , combinationenums.titlebar) = combinationenums.titlebar   window.titlebar = true end if 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -