We all know the effects that lots of thrown exceptions can have over the performance of our applications, thus, we should stay away from things like using exceptions for control flow.
After this statement I must confess that when coding I didn't care that much about this. I've been working mostly on Java platform but lately I was doing it on .NET platform and just found out this handy method: public static bool TryParse(string s,out int result)
,which allows you to transform a String into int whithout raise an exception. From that moment on, I'm keeping on using it. I just wanted to ask you about your preferences regarding the use of public static bool TryParse(string s,out int result)
or public static int ToInt32(string value)
.
And from the point of view of Java, just pointing that it's missing such a similar method, despite we could get it through things like:
boolean isInteger = Pattern.matches("^\d*$", myString);
Thanks.