string liquidClass = string.Empty;
switch (cmbLiquidClass.Text)
{
case "LiquidClass1":
liquidClass = Settings.Default.LiquidClass1;
break;
case "LiquidClass2":
liquidClass = Settings.Default.LiquidClass2;
break;
case "LiquidClass3":
liquidClass = Settings.Default.LiquidClass3;
break;
case "LiquidClass4":
liquidClass = Settings.Default.LiquidClass4;
break;
case "LiquidClass5":
liquidClass = Settings.Default.LiquidClass5;
break;
case "LiquidClass6":
liquidClass = Settings.Default.LiquidClass6;
break;
case "LiquidClass7":
liquidClass = Settings.Default.LiquidClass7;
break;
case "LiquidClass8":
liquidClass = Settings.Default.LiquidClass8;
break;
case "LiquidClass9":
liquidClass = Settings.Default.LiquidClass9;
break;
}
Trying to get in to a local variable the contents of the current class. I can’t use a dictionary because of the way strings work (behaving like value types). Is there any way to refactor this so that it doesn’t require this many lines to find the chosen liquid class?
You can use the indexer that is part of
Settings.Default(tested with .Net 4.0):