throw
usually causes the function to terminate immediately, so you even if you do put any code after it (inside the same block), it won't execute. This goes for both C++ and C#. However, if you throw an exception inside a try
block and the exception gets caught, execution will continue in the appropriate catch
block, and if there is a finally
block (C# only), it will be executed whether an exception is thrown or not. At any rate, any code immediately after the throw
will never be executed.
(Note that having a throw
directly inside a try
/catch
is usually a design problem - exceptions are designed for bubbling errors up across functions, not for error handling within a function.)