I have ENUMs and extensions in my application that I use like this:
public enum CO
{
Random = 0,
FirstToLast = 1,
LastToFirst = 2,
}
public static partial class Extensions
{
public static string Text(this CO cardOrder)
{
switch (cardOrder)
{
case CO.Random: return "Random";
case CO.FirstToLast: return "1, 2, 3";
case CO.LastToFirst: return "3, 2, 1";
}
return "";
}
}
In the codes I have switch statement set to decide to update a database:
switch (segControlCardOrder.SelectedValue)
{
case "Random":
App.DB.UpdateIntSetting(SET.Co, (int)CO.Random);
break;
case "1, 2, 3":
App.DB.UpdateIntSetting(SET.Co, (int)CO.FirstToLast);
break;
case "3, 2, 1":
App.DB.UpdateIntSetting(SET.Co, (int)CO.LastToFirst);
break;
}
Is there a way that I could avoid using the switch statement and just call the UpdateIntSettings based on the value of the ENUM?