We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 566cd50 commit 09ce194Copy full SHA for 09ce194
1 file changed
src/web/Jordnaer/Extensions/EnumExtensions.cs
@@ -0,0 +1,14 @@
1
+using System.ComponentModel.DataAnnotations;
2
+using System.Reflection;
3
+
4
+namespace Jordnaer.Extensions;
5
6
+public static class EnumExtensions
7
+{
8
+ public static string? ToDisplayName<T>(this T enumValue) where T : Enum =>
9
+ enumValue.GetType()
10
+ .GetMember(enumValue.ToString())
11
+ .First()
12
+ .GetCustomAttribute<DisplayAttribute>()?
13
+ .Name;
14
+}
0 commit comments