//Execute the appropriate method - n.b. no if statements in sight! public void DealWithConditions() { HelmetState helmetState = GetHelmetState(formvalues["helmets"]); GarageState garageState = GetGarageState(formvalues["garages"]); ExecuteCondition[Key(helmetState, garageState)](); }
//gets a unique value for each HelmetState/GarageState combination to be used as a key to the dictionary private int Key(HelmetState helmetState, GarageState garageState) { return((int)helmetState + (int)garageState); }