Last active
August 29, 2015 14:03
-
-
Save JohnLudlow/262bc2300bf09184fe1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Extensions | |
{ | |
public static TEnum AsEnum<TEnum>(this string input, Func<string, TEnum> func) | |
{ | |
return func(input); | |
} | |
public static TEnum AsEnum<TEnum>(this string input) | |
{ | |
return (TEnum)Enum.Parse(input, typeof(TEnum)); | |
} | |
public static TEnum AsEnum<TEnum>(this string input, bool ignoreCase) | |
{ | |
return (TEnum)Enum.Parse(input, typeof(TEnum), ignoreCase); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment