How to get string representation of an Enum in C#? Problem with ToString()
Hello everyone! I'm a beginner C# developer and I've encountered a problem when working with enums. I have this code:
```csharp
public enum StatusCode
{
Success = 200,
NotFound = 404,
ServerError = 500
}
StatusCode status = StatusCode.Success;
Console.WriteLine(status); // Outputs "Success"
```
At first glance everything works — ToString() by default returns the constant name. But when I tried to use this in a more complex scenario, for example, for logging or saving to a database, problems arose. I need to get a string like "200" (the numeric value), not "Success". Also, I want the string representation to be more flexible: for example, contain spaces (like "Not Found" instead of "NotFound") or be localized.
I've tried different options