From 5168948a1df6350289a5daafc037d429df6b256e Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 20 Apr 2022 14:09:13 +0100 Subject: [PATCH] Use generic Enum.GetValues --- X10D/src/EnumExtensions/EnumExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/X10D/src/EnumExtensions/EnumExtensions.cs b/X10D/src/EnumExtensions/EnumExtensions.cs index 06eb531..02b80fe 100644 --- a/X10D/src/EnumExtensions/EnumExtensions.cs +++ b/X10D/src/EnumExtensions/EnumExtensions.cs @@ -21,7 +21,7 @@ public static class EnumExtensions public static T Next(this T source, bool wrap = true) where T : struct, Enum { - var array = (T[])Enum.GetValues(source.GetType()); + var array = Enum.GetValues(); int index = Array.IndexOf(array, source) + 1; return array.Length == index ? array[wrap ? 0 : index - 1] : array[index]; } @@ -42,7 +42,7 @@ public static class EnumExtensions public static T Previous(this T source, bool wrap = true) where T : struct, Enum { - var array = (T[])Enum.GetValues(source.GetType()); + var array = Enum.GetValues(); int index = Array.IndexOf(array, source) - 1; return index < 0 ? array[wrap ? array.Length - 1 : 0] : array[index]; }