Contains extension methods for humanizing Enums
public static class EnumHumanizeExtensionsInheritance System.Object → EnumHumanizeExtensions
Converts an enum value to a human-readable string when the concrete enum type is only known at runtime.
public static string Humanize(this System.Enum input);input System.Enum
The enum value to be humanized.
System.String
A human-readable string representation of the enum value.
Converts an enum value to a human-readable string with the specified letter casing applied to the enum member name when the concrete enum type is only known at runtime. Authored metadata on a defined enum value is returned unchanged.
public static string Humanize(this System.Enum input, Humanizer.LetterCasing casing);input System.Enum
The enum value to be humanized.
casing LetterCasing
The desired letter casing to apply when humanizing the enum member name.
System.String
A human-readable string representation of the enum value.
Converts an enum value to a human-readable string using the specified casing and source when the concrete enum type is only known at runtime.
public static string Humanize(this System.Enum input, Humanizer.LetterCasing casing, Humanizer.EnumHumanizeSource source);input System.Enum
The enum value to be humanized.
casing LetterCasing
The desired letter casing to apply when humanizing the enum member name.
source EnumHumanizeSource
The source used to humanize the enum value.
System.String
A human-readable string representation of the enum value.
Converts an enum value to a human-readable string by intelligently formatting the enum member name and respecting any System.ComponentModel.DescriptionAttribute applied to the member.
public static string Humanize<T>(this T input)
where T : struct, System.Enum;T
The enum type. Must be a struct and implement System.Enum.
input T
The enum value to be humanized.
System.String
A human-readable string representation of the enum value.
If the enum has the System.FlagsAttribute and multiple flags are set, returns a humanized,
comma-separated list of the flag values.
If a System.ComponentModel.DescriptionAttribute is present on the enum member, its value is returned.
Otherwise, the enum member name is humanized (e.g., "AnonymousUser" becomes "Anonymous user").
enum UserType { AnonymousUser, RegisteredUser }
UserType.AnonymousUser.Humanize() => "Anonymous user"
[Flags]
enum Permission { None = 0, Read = 1, Write = 2, Delete = 4 }
(Permission.Read | Permission.Write).Humanize() => "Read, Write"
enum Status
{
[Description("Currently active")]
Active
}
Status.Active.Humanize() => "Currently active"For flags enums, only non-zero flags are included in the output, and each flag is humanized individually. The humanization process converts PascalCase to space-separated text with appropriate capitalization.
Converts an enum value to a human-readable string with the specified letter casing applied to the enum member name. Authored metadata on a defined enum value is returned unchanged.
public static string Humanize<T>(this T input, Humanizer.LetterCasing casing)
where T : struct, System.Enum;T
The enum type. Must be a struct and implement System.Enum.
input T
The enum value to be humanized.
casing LetterCasing
The desired letter casing to apply when humanizing the enum member name.
System.String
A human-readable string representation of the enum value.
If a defined enum value has authored metadata such as System.ComponentModel.DescriptionAttribute, its value is returned unchanged.
enum UserType { AnonymousUser, RegisteredUser }
UserType.AnonymousUser.Humanize(LetterCasing.AllCaps) => "ANONYMOUS USER"
UserType.AnonymousUser.Humanize(LetterCasing.Title) => "Anonymous User"
UserType.AnonymousUser.Humanize(LetterCasing.LowerCase) => "anonymous user"For a defined enum value, the specified casing is applied only when the output is derived from the enum member name.
Converts an enum value to a human-readable string using the specified casing and source.
public static string Humanize<T>(this T input, Humanizer.LetterCasing casing, Humanizer.EnumHumanizeSource source)
where T : struct, System.Enum;T
The enum type. Must be a struct and implement System.Enum.
input T
The enum value to be humanized.
casing LetterCasing
The desired letter casing to apply when humanizing the enum member name.
source EnumHumanizeSource
The source used to humanize the enum value.
System.String
A human-readable string representation of the enum value.