From af3dfaa623a1d02d694c7d93dd3956b7cd4db6a5 Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Tue, 20 Jul 2021 17:25:52 +0100 Subject: [PATCH] (#14) Pattern-match IsEnum property on typeof(T) --- X10D/src/StringExtensions/StringExtensions.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/X10D/src/StringExtensions/StringExtensions.cs b/X10D/src/StringExtensions/StringExtensions.cs index 5b4b87b..0f64705 100644 --- a/X10D/src/StringExtensions/StringExtensions.cs +++ b/X10D/src/StringExtensions/StringExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -134,9 +134,7 @@ namespace X10D throw new ArgumentException(Resource.EnumParseEmptyStringException, nameof(value)); } - var type = typeof(T); - - if (!type.IsEnum) + if (typeof(T) is not { IsEnum: true } type) { throw new ArgumentException(Resource.EnumParseNotEnumException); }