[C#] String in Enum wandeln

public enum MyType
{
    Undef = 0,
    Type1 = 10,
    Type2 = 20,
    Type3 = 64
}

// Variante 1 mit Parse
string sType = "Type1";
MyType t = (MyType)Enum.Parse(typeof(MyType), sType);

// Variante 2 mit TryParse
MyType a;
string sType = "Type1";

// Inhalt von string "sType" bestimmen und in MyType wandeln
// Ergebnis in "a" ausgeben
if (Enum.TryParse<MyType->(sType, out a))
{
    ...
}