Posted on: 4/15/2015 6:20:05 PM | Views : 652

I have an enum set up with Flags attribute and it seems to be working ok, but what's the best method for setting those values based on boolean values similar to checkboxes?
Example:
[Flags] public enum TransactionCodeFlags { All = 1, First = 2, Second = 4, Third = 8, Fourth = 16, Fifth = 32, Sixth = 64, Seventh = 128, } Then I can set like this:
TransactionCodeFlags tflags = (TransactionCodeFlags.First | TransactionCodeFlags.Fifth) Now let's say I have 7 different checkboxes that designate First - Seventh, how do I translate those over?
if (cbFirst.Checked == true) { //add first to flag? }if (cbSecond.Checked == true){ //add second to flag?}

Go to the complete details ...