I have 6x checkboxes, which represent filters and are booleans. These filters type are represented by an enum. I need to get a List depending on the state of the checkboxes and I'm trying to do it the right way.
Currently I have my 6x checkboxes, which are all boolean:
bool checkbox1Filter1bool checkbox2Filter2//...I have an enum which looks like this with 6x values:
public enum MyFilters : byte{ Filter1 = 12, Filter2 = 30, // ...}I currently have a function which adds my filters in a list depending on the state of the checkboxes:
function List<MyFilters> GetMyFilters(){ var lst = new List<MyFilters>(); if (checkbox1Filter1) { lst.Add(MyFilters.Filter1) } if (checkbox2Filter2) { lst.Add(MyFilters.Filter2) } // ... return lst;}Basically I would like to completely get rid of that function and do something smarter with less 'if' everywhere. Could a Dictionary<MyFilters,bool> do the trick ?