mirror of https://github.com/oliverbooth/X10D
Add Enum constraint to string.EnumParse<T>
This commit is contained in:
parent
af3dfaa623
commit
3bbf689db4
|
@ -105,6 +105,7 @@ namespace X10D
|
||||||
/// (http://geekswithblogs.net/sdorman/Default.aspx).
|
/// (http://geekswithblogs.net/sdorman/Default.aspx).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static T EnumParse<T>(this string value)
|
public static T EnumParse<T>(this string value)
|
||||||
|
where T : struct, Enum
|
||||||
{
|
{
|
||||||
return value.EnumParse<T>(false);
|
return value.EnumParse<T>(false);
|
||||||
}
|
}
|
||||||
|
@ -121,6 +122,7 @@ namespace X10D
|
||||||
/// (http://geekswithblogs.net/sdorman/Default.aspx).
|
/// (http://geekswithblogs.net/sdorman/Default.aspx).
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static T EnumParse<T>(this string value, bool ignoreCase)
|
public static T EnumParse<T>(this string value, bool ignoreCase)
|
||||||
|
where T : struct, Enum
|
||||||
{
|
{
|
||||||
if (value is null)
|
if (value is null)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue