I have seen suggestions for both but would like to confirm that this is the best way to do this:
public enum MO
{
Learn = 0,
Practice = 1,
Quiz = 2
}
public static partial class Extensions
{
public static MO ToMode(this string mode)
{
switch (mode)
{
case "Learn": return MO.Learn;
case "Practice": return MO.Practice;
case "Quiz": return MO.Quiz;
default: throw new InvalidEnumArgumentException("Unhandled value: " + mode.ToString());
}
}
}