I have two enums:
public enum Fruits { Apple = 1, Banana = 2, Strawberry = 3, Blueberry = 4 } public enum FruitsCombined { Apple = 1, Banana = 2, Berries = 0 //Strawberry and Blueberry combined } I have a Combobox, which is bound to the FruitsCombined enum, but in the background, when I select Berries, I want to say it's 3 and 4 from the Fruits enum.
How can I do this?
For example, I want to replace this for a better way, with the two enums:
if ((int)cboFilterFruitType.SelectedValue == 0) { order = order.FindAll(o => o.FruitID == 3 || o.FruitID == 4); } else { order = order.FindAll(o => o.FruitID == (int) cboFilterFruitType.SelectedValue); }
Flags?0as a value for any meaningful enum value because that's the value ofdefault(TEnum). So you should changeBerries = 0toBerries = 3- or better-yet:Berries = 7(because7 == 3 | 4).