Re: Variables in catch(...) clauses?
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 02/26/04
- Next message: Kael V. Dowdy: "Re: MCSD VisualBasic6.0"
- Previous message: Me2: "Re: Variables in catch(...) clauses?"
- In reply to: Me2: "Re: Variables in catch(...) clauses?"
- Next in thread: C# Learner: "Re: Variables in catch(...) clauses?"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 26 Feb 2004 13:45:27 -0000
Me2 <r@r.com> wrote:
> I have taken and passed the Web and Windows coding exams and I don't
> remember any questions that dealt with whether the exception variable should
> or should not be used. I agree with you that if you are not going to
> inspect the exception codes that are passed back, then why include the
> variable. Would omitting the variable cause the resulting IL code to
> execute faster or slower?
The IL generated when there's no variable just pops the exception off
the stack. Basically, I expect there'll be no significant difference in
execution speed.
> As far as having the explicit catch clauses for exceptions, you should have
> the catch "all" after the specific tested exceptions in case something bombs
> that you did not expect.
Only if you actually *want* to catch everything, which you often don't
want to. You may well have a couple of places in the whole code where
you want to catch everything, but many other places where you want to
only catch specific exceptions.
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Kael V. Dowdy: "Re: MCSD VisualBasic6.0"
- Previous message: Me2: "Re: Variables in catch(...) clauses?"
- In reply to: Me2: "Re: Variables in catch(...) clauses?"
- Next in thread: C# Learner: "Re: Variables in catch(...) clauses?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|