Skip to main content
Version: 2.13.14

Humanizer.EnumDehumanizeExtensions

EnumDehumanizeExtensions Class

Contains extension methods for dehumanizing Enum string values.

public static class EnumDehumanizeExtensions

Inheritance System.Object → EnumDehumanizeExtensions

Methods

EnumDehumanizeExtensions.DehumanizeTo(this string, Type, OnNoMatch) Method

Dehumanizes a string into the Enum it was originally Humanized from!

public static System.Enum DehumanizeTo(this string input, System.Type targetEnum, Humanizer.OnNoMatch onNoMatch=Humanizer.OnNoMatch.ThrowsException);

Parameters

input System.String

The string to be converted

targetEnum System.Type

The target enum

onNoMatch OnNoMatch

What to do when input is not matched to the enum.

Returns

System.Enum

Exceptions

NoMatchFoundException
Couldn't find any enum member that matches the string

System.ArgumentException
If targetEnum is not an enum

EnumDehumanizeExtensions.DehumanizeTo<TTargetEnum>(this string) Method

Dehumanizes a string into the Enum it was originally Humanized from!

public static TTargetEnum DehumanizeTo<TTargetEnum>(this string input)
where TTargetEnum : struct, System.IComparable, System.IFormattable;

Type parameters

TTargetEnum

The target enum

Parameters

input System.String

The string to be converted

Returns

TTargetEnum

Exceptions

System.ArgumentException
If TTargetEnum is not an enum

NoMatchFoundException
Couldn't find any enum member that matches the string