On Mon, 7 Feb 2005 22:18:41 -0000, Nicko Cadell <[EMAIL PROTECTED]> wrote: > I have run a little perf test. > > When parsing valid data the TryParse method is 50% slower than > int.Parse. This difference is expected, it may even be rather less than > anticipated. > When parsing invalid data the int.Parse (throwing exceptions) is 90 > times slower than TryParse!
Wow! That really shows why you don't want to use Exceptions to handle expected conditions! Unfortunaly, the Tryxxx approach can't be taken too far or you would end up with a TryXxx for every Xxx. In this case, perhaps you could do a "cursory" validation (e.g., test if all characters are digits) before invoking Parse. Mike
