How else?
Int32.Parse
cannot be successful for any arbitrary string. Isn't it obvious? You can always validate it and recover from this exception is you handle it by putting the call in some try-catch block with appropriate exception handling, or, better, just using
Int32.TryParse
instead:
https://msdn.microsoft.com/en-us/library/system.int32.tryparse%28v=vs.110%29.aspx[
^].
Interestingly, if you read .NET BCL source code, you will see that
TryParse
methods don't use exception handling internally, instead, they prevent throwing exceptions.
—SA