Review the code snippet before inserting it on your project.
/// /// Check to see if string Is A Number /// /// String number to check /// bool - true if string is a real number private bool IAN(string i) { try { int.Parse(i); } catch { return false; } return true; }
I simply needed a quick way to determine if a string was a number. I didn't care what it was, and for a web app, the catch has a minimal impact. Besides I didnt know of the TryParse at the time , thanks.
All the objects (int included) that have a Parse have a TryParse method already. You are relying on an exception to be thrown, that is fairly expensive. Most of the time you are actually going to want the conversion done if it is a number anyway. Just use: int dummy; int.TryParse(i, out dummy);
With from Barcelona