Exceptions: When to use, timing, overall use

后端 未结 6 1527
-上瘾入骨i
-上瘾入骨i 2020-12-20 07:47

I\'ll try and ask my question so it doesn\'t end as a simple argumentative thread.

I\'ve jumped into an application coded in C# recently and I\'m discovering the exc

6条回答
  •  伪装坚强ぢ
    2020-12-20 08:45

    Exceptions should be used for exceptional behavior, not for flow-control. A basic guideline would be that if normal program flow regularly runs into exceptions you're doing something wrong.

    However, it is important to notice that just having a try { } catch { } present will itself not affect performance negatively. Only when an exception is actually thrown and the stack trace needs to be computed you will see (in some cases quite severe) performance degradation.

提交回复
热议问题