Performing a “Return” from a Try Block

Exception handling on Windows mailboxes (at least for C ++) leads to performance hit if you exit the try block prematurely (for example, execute the return statement) just as if an exception were thrown.

But what about C #? Is performance a hit to return prematuraly from a try block, whether through a return or break statement?

+5
source share
3 answers

If there is a performance hit, it is tiny. This, of course, is not the same as catching an exception. (And even this is not as bad as many people think.)

, try . - 0. , , / - , .

+7

, , - try.

, try, , try, , .

try ( 0,000002 ), .

+3

All exception handling takes on a small overhead - there is always additional work that needs to be done for any existing try / catch.

The question is not whether it is, but whether it is RELATIVE. If I need to catch an exception, I need. No arguing about performance.

-1
source

All Articles