Does 'throw' or 'try...catch' hinder performance?

Posted by Richard on Stack Overflow See other posts from Stack Overflow or by Richard
Published on 2010-04-26T13:11:41Z Indexed on 2010/04/26 13:13 UTC
Read the original article Hit count: 143

Filed under:
|

I've been reading all over the place (including here) about when exception should / shouldn't be used. I now want to change my code that would throw to make the method return false and handle it like that, but my question is: Is it the throwing or try..catch-ing that can hinder performance...? What I mean is, would this be acceptable:


bool method someMmethod()
{
    try
    {    
        // ...Do something
    catch (Exception ex) // Don't care too much what at the moment...
    {
        // Output error
        // Return false
    }
    return true // No errors

Or would there be a better way to do it? (I'm bloody sick of seeing "Unhandled exception..." LOL!)

© Stack Overflow or respective owner

Related posts about c#

Related posts about exceptions