In practice both cases do exactly the same. Also, they are completely redundant, only waste CPU time.
Please find more detailed explanation in my comment to the (incorrect) Answer by avigodse.
Now this answer is improved. Avigodse probably understands correctly how exception works, only it requires additional explanation. Declaration
ex
is the last code sample of the Question suggests some processing can be added before re-throwing exception. Until it is not done, both samples do the same and completely redundant. See my comment to the mentioned Answer.
It's very important not to block propagation of exceptions up to stack, so in many cases the exception should be re-thrown. If special processing is needed, the specialized type of exception should be used (of a type derived from
System.Exception
). This type is the best to report all exceptions and/or log them or created exception dump to report problems for CodeProject Questions :-).
See my additional instructions on using exception:
How do i make a loop that will stop when a scrollbar reaches the bottom[
^]
When i run an application an exception is caught how to handle this?[
^]
I tried to list best practices.
—SA