.TryParse(), .Parse() vs. just try/catch

I’ve read many times that catching an exception is expensive, so it should be avoided when possible. For example, instead of trying to cast/convert an object and catch the InvalidCastException, instead see if there is a built-in way.
For example, most of the value types in the .NET framework have a TryParse() and Parse(). Well, see this blog post, they go into a good amount of detail about how there isn’t much different performance-wise if all goes well; but if there is an exception, the difference becomes HUGE performance-wise! This is a good read:
Posted in Best-practices, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


Enter your email address to follow this blog and receive notifications of new posts by email.

Join 8 other followers

%d bloggers like this: