In Throw, the original exception stack trace will be retained. To keep the original stack trace information, the correct syntax is ‘throw’ without specifying an exception. In Throw ex, the original stack trace information will get override and you will lose the original exception stack trace.
Interviews9 answers
What is difference between the “throw” and “throw ex” in .NET?
9 Answers
Rajeev KumarPosted Mar 31, 2023, 3:41 AM EDT
throw reset the stack trace so we can get line number of error .by using throw we can get all exception information.but throw ex does not reset stack trace so that's why it will give only original information of exception.
kajal ranePosted Apr 7, 2019, 1:10 AM EDT
throw ex resets the stack trace (so your errors would appear to originate from HandleException)
throw doesn't - the original offender would be preserved.
Bharathi RajaPosted Jan 19, 2018, 8:48 PM EST
throw ex resets the stack trace (so your errors would appear to originate from HandleException)
throw doesn't - the original offender would be preserved.
Bharathi RajaPosted Jan 19, 2018, 8:48 PM EST
throw ex resets the stack trace (so your errors would appear to originate from HandleException)
throw doesn't - the original offender would be preserved.
Bharathi RajaPosted Jan 19, 2018, 8:48 PM EST
throw ex resets the stack trace (so your errors would appear to originate from HandleException)
throw doesn't - the original offender would be preserved.
Bharathi RajaPosted Jan 19, 2018, 8:48 PM EST
throw ex resets the stack trace (so your errors would appear to originate from HandleException)
throw doesn't - the original offender would be preserved.
Bharathi RajaPosted Jan 19, 2018, 8:48 PM EST
Throw provide actual error
Throw ex provide the stack trace
Rajani PandeyPosted Jan 7, 2018, 7:26 AM EST
“Throw” statement preserves original error stack whereas “throw ex” have the stack trace from their throw point. It is always advised to use “throw” because it provides more accurate error information.
Pradeep YadavPosted May 24, 2017, 5:48 AM EDT


