Performance Considerations for throwing Exceptions

前端 未结 8 1100
旧时难觅i
旧时难觅i 2020-12-19 03:17

I have come across the following type of code many a times, and I wonder if this is a good practice (from Performance perspective) or not:

try
{
    ... // s         


        
8条回答
  •  -上瘾入骨i
    2020-12-19 04:08

    Like David, I suppose that the second and third perform better. But would any one of the three perform poorly enough to spend any time worrying about it? I think there are larger problems than performance to worry about.

    FxCop always recommends the third approach over the second so that the original stack trace is not lost.

    Edit: Removed stuff that was just plain wrong and Mike was kind enough to point out.

提交回复
热议问题