-
Many parsing API looks like following: public static bool TryParse(string input, out SomeType result)
{
} When method returns false, is it allowed to use Moreover, if |
Beta Was this translation helpful? Give feedback.
Answered by
EgorBo
Aug 16, 2021
Replies: 1 comment 2 replies
-
In my view, cases where TryParse fails are (expected to be) rare so it's not that important to optimize. And returning junk in TryParse(input, out MyStruct ms);
if (ms.Id != 0) // Id will be some random value in case of failed TryParse
{
... |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
sakno
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In my view, cases where TryParse fails are (expected to be) rare so it's not that important to optimize. And returning junk in
out
doesn't look safe. E.g.