C# provides the facility to handle exceptions using the try and catch block. There are two ways -- you can either use throw(ex) method or the simpler throw method, as below.
First Way
First Way
- try
- {
- }
- catch(Exception ex)
- {
- throw;
- }
Second way
Now, the question arises -- which one is better?
Here is the screenshot of a simple program.
- try
- {
- }
- catch(Exception ex)
- {
- throw(ex);
- }
Here is the screenshot of a simple program.
The Throw method throws the current exception only while the Throw(ex) method will reset your stack trace so the error will appear from the line where Throw(ex) is written. Since Throw does not reset the stack trace, you will get the information about the original exception. Throw (ex) gives the following Exception Message.
at ConsoleApp1.Program.Main(String[] args) in D:\INTW\Console\ConsoleApp1\ConsoleApp1\Program.cs:line 19
And, Throw sends this Exception Message.
at ConsoleApp1.Program.DevideByZero(Int32 i) in D:\INTW\Console\ConsoleApp1\ConsoleApp1\Program.cs:line 26
at ConsoleApp1.Program.Main(String[] args) in D:\INTW\Console\ConsoleApp1\ConsoleApp1\Program.cs:line 19
And, Throw sends this Exception Message.
at ConsoleApp1.Program.DevideByZero(Int32 i) in D:\INTW\Console\ConsoleApp1\ConsoleApp1\Program.cs:line 26
at ConsoleApp1.Program.Main(String[] args) in D:\INTW\Console\ConsoleApp1\ConsoleApp1\Program.cs:line 19
So, you can see in the above image, we have got full stack trace information where the actual exception is called at line 26 and again rethrown at line 19.
While in the first screenshot, you can see there is only information about line 19. It does not show a full-stack trace. So, I will recommend you to always use Throw method.

Priyanka YadavPosted Feb 15, 2019, 3:00 AM
Nice article!!
Pravin LalgePosted Aug 23, 2018, 12:41 AM
Thanks shruti for feedback.
Shruti SopalPosted Aug 23, 2018, 12:39 AM
Good explanation . Thanks Pravin . Keep it up
Sumit RajguruPosted Aug 16, 2018, 4:25 AM
Nice one. Explained very well
Sukesh GandhamPosted Aug 10, 2018, 1:50 AM
Thanks for sharing!!!
Vijay YadavPosted Aug 3, 2018, 3:23 AM
Nice article dude, keep it up
kashid siddhuPosted Aug 3, 2018, 1:04 AM
It's very good explanation, it's easy to understand the difference of throws & throws ex
Rahul PatilPosted Aug 3, 2018, 12:39 AM
Very useful Pravin..Thanks!!
Karthik ChintalaPosted Aug 3, 2018, 12:11 AM
Good explanation pravin