Open sandboxFocus

Method ToStringSafe

ToStringSafe(Enum)

Returns a deterministic string representation of an enum value. For enums with alias members (multiple names sharing the same underlying value, e.g. Default = 0, Success = 0), the built-in ToString() picks one of the names in an implementation-defined way that can vary across .NET runtimes. This method returns the alphabetically-first preferred name among aliases — names marked [Obsolete] and the literal name Default are deprioritized and only used as a fallback when no preferred alias exists, so diagnostic messages and log output stay stable.

Declaration
public static string ToStringSafe(this Enum value)
Parameters
Type Name Description
Enum value
Returns
Type Description
string