4 ms·
I think that having alternatives to try/catch is generally worthwhile. Exceptions should only be thrown in exceptional circumstances. So (to take some C# code
by AndrewDucker 15y ago
I think that having alternatives to try/catch is generally worthwhile. Exceptions should only be thrown in exceptional circumstances.
So (to take some C# code as an example), I'd only call int.parse(myString) if it really, really should only get called when myString contains something that's parseable to an integer.
If it just probably contains an integer, then I'd call int.TryParse(myString, out returnedInt), and check the boolean return to see whether it was valid.