.

Generic Enum parser

public static class MyExtensions
{
    public static TEnum ParseEnum<TEnum>(this string value,
        bool ignoreCase = false) where TEnum : struct
    {
        TEnum tenumResult;
        Enum.TryParse<TEnum>(value, ignoreCase, out tenumResult);
        return tenumResult;
    }
}

usage: 
var enumValue = "One".ParseEnum<EnumOne>();

What's your thoughts on this?

*

Protected by WP Anti Spam