3

Possible Duplicate:
Performance Cost Of 'try' in C#

Hi lets say two similar codes (func A calling B, B calling C, C calling D and so on) are available with following slight difference: CODE 1: no try catch finally block is writen in code. CODE 2: each method has a try catch block within.

if no exception is thrown, is there any performance difference?

thanks.

Community
  • 1
  • 1
Azodious
  • 13,752
  • 1
  • 36
  • 71
  • Forget performance: there is a semantic difference. The two pieces of code have different behaviors. You cannot compare a fast program that outputs garbage with one that works correctly. – R. Martinho Fernandes Feb 11 '11 at 11:49
  • @Martinho Fernandes: What? Who said either approach output garbage? – Lazarus Feb 11 '11 at 11:51
  • yes, true. there is semantic difference. but they have same behaviors. – Azodious Feb 11 '11 at 12:00
  • @Azodious: They don't have the same behavior. When there is an error in the first execution terminates. When there is an error in the second you do something with it. @Lazarus: because the two behave differently, it's more important to get the one that has the desired behavior than the one that doesn't. – R. Martinho Fernandes Feb 11 '11 at 12:00
  • @Martin i agree, but in question i said that no exception in thrown. so do they have same behaviour? output-wise : YES performance : looking for answer. – Azodious Feb 11 '11 at 12:28
  • @Azodious: oh, my missed. I somehow missed the part about no exception thrown. Sorry for the confusion. – R. Martinho Fernandes Feb 11 '11 at 12:31

0 Answers0