Open sandboxFocus

Method IsValidEnumValue

IsValidEnumValue(string, Type)

Determines whether the specified string value is a valid member of the specified enumeration type.

Declaration
public static bool IsValidEnumValue(string value, Type enumType)
Parameters
Type Name Description
string value

The string value to validate. Null or empty strings are considered valid.

Type enumType

The enumeration type to validate against.

Returns
Type Description
bool

true if the value is valid for the enumeration; otherwise, false.

IsValidEnumValue(object?, Type)

Determines whether the specified object value is a valid member of the specified enumeration type.

Declaration
public static bool IsValidEnumValue(object? value, Type enumType)
Parameters
Type Name Description
object value

The value to validate. Null values are considered valid. If the value is a string, it is matched against enum member names.

Type enumType

The enumeration type to validate against.

Returns
Type Description
bool

true if the value is valid for the enumeration; otherwise, false.