3 ms·
Enum.TryParse Unexpected Behavior
- freedude 3y ago"Enum.TryParse does the following: Converts the string representation of the name or numeric value of one or more enumerated constants to an equivalent enumerated object. The return value indicates whether the conversion succeeded. "
- freedude 3y agoReference: A better enumeration - Type safe from start to end https://steven-giesel.com/blogPost/74c47c63-ebf0-44d9-85af-d4e4803a63b4 https://steven-giesel.com/blogPost/74c47c63-ebf0-44d9-85af-d...
- colejohnson66 3y agoI would argue that using `Enum.TryParse` on integers means you're doing something wrong. If I have an integer, even if it's as a string, I can just cast it to the enum type (after parsing the string if needed), hence why `Enum.IsDefined` exists.