From 3bbf689db42a805d5a4f19da19731cc308b4096a Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 20 Jul 2021 17:29:26 +0100 Subject: [PATCH] Add Enum constraint to string.EnumParse --- X10D/src/StringExtensions/StringExtensions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/X10D/src/StringExtensions/StringExtensions.cs b/X10D/src/StringExtensions/StringExtensions.cs index 0f64705..c62fb9b 100644 --- a/X10D/src/StringExtensions/StringExtensions.cs +++ b/X10D/src/StringExtensions/StringExtensions.cs @@ -105,6 +105,7 @@ namespace X10D /// (http://geekswithblogs.net/sdorman/Default.aspx). /// public static T EnumParse(this string value) + where T : struct, Enum { return value.EnumParse(false); } @@ -121,6 +122,7 @@ namespace X10D /// (http://geekswithblogs.net/sdorman/Default.aspx). /// public static T EnumParse(this string value, bool ignoreCase) + where T : struct, Enum { if (value is null) {