Using Exceptions throwing in C#. Does it affect a performance?

后端 未结 8 871
余生分开走
余生分开走 2021-01-13 01:58

Basically, the question is: Do the Exceptions in C# affect the performance a lot? Is it better to avoid Exceptions rethrow? If i generate an exception in my code, does it a

8条回答
  •  暖寄归人
    2021-01-13 02:43

    running code through a try/catch statement does not affect performance at all. The only performance hit comes if an exception is thrown ... because then the runtime has to unwind the stack and gather other information in order to populate the exception object.

提交回复
热议问题