Why is CoreCLR Int32.TryParse not done in the most optimal way? #92591
-
Hi all. I would like to know why Int32.TryParse is designed this way. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Because by spec an erroneous number style needs to result in an exception regardless of the string to be parsed. Otherwise, you only know that you're holding it wrong for some input strings. |
Beta Was this translation helpful? Give feedback.
-
OK. The answer suits me, although I think this behavior is strange :) |
Beta Was this translation helpful? Give feedback.
Because by spec an erroneous number style needs to result in an exception regardless of the string to be parsed. Otherwise, you only know that you're holding it wrong for some input strings.