Class StringEnum<T>
Generic string enum implementation.
public abstract record StringEnum<T> : IEquatable<StringEnum<T>> where T : StringEnum<T>, new()
Type Parameters
T
Particular StringEnum<T> implementation type.
- Inheritance
-
StringEnum<T>
- Implements
-
IEquatable<StringEnum<T>>
- Derived
Properties
None
Gets empty enum value.
public static T None { get; }
Property Value
- T
Empty value.
Unknown
Gets unknown enum value.
E.g. that cannot be parsed.
public static T Unknown { get; }
Property Value
- T
Unknown value.
Methods
Define(string)
Defines new enum entry and adds it to the values dictionary.
protected static T Define(string value)
Parameters
value
stringEnum entry value.
Returns
- T
Created enum entry instance.
Equals(T?)
public virtual bool Equals(T? other)
Parameters
other
T
Returns
Find(string?)
Finds enum entry by the specified string value.
public static T Find(string? value)
Parameters
value
stringString value to find enum entry for.
Returns
- T
Enum entry for the specified string value if found, null otherwise.
Remarks
Search is case-sensitive.
GetHashCode()
public override int GetHashCode()
Returns
ToString()
public override sealed string ToString()