Enum.TryParse missing in Windows Phone 7

It’s not present in the WP7 version of mscorlib. Eventually I wrote code like this:

ForumType forumType = ForumType.Unknown;

    string enumLine = forumTypeInput.Substring(. . .);
    forumType = (ForumType)Enum.Parse(
        typeof(ForumType), enumLine.Trim(), true);
catch (ArgumentException)

Note how I only catch (and swallow) ArgumentException. The call can throw an ArgumentNullException too but that would indicate an application code error, so you should not swallow it. Any other unhandled errors also need to be correctly handled so this is the only exception you should swallow. Kinda surprising they decided to drop TryParse though, since it’s not a particularly heavy method.