Interviews - C# Corner

Pradeep Yadav
What is difference between the “throw” and “throw ex” in .NET?
By Pradeep Yadav in C# onMay 24 2017
  • kajal rane
    Apr, 2019 7

    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.

    • 0
  • Bharathi Raja
    Jan, 2018 20

    throw ex resets the stack trace (so your errors would appear to originate from HandleException) throw doesn't - the original offender would be preserved.

    • 0
  • Bharathi Raja
    Jan, 2018 20

    throw ex resets the stack trace (so your errors would appear to originate from HandleException) throw doesn't - the original offender would be preserved.

    • 0
  • Bharathi Raja
    Jan, 2018 20

    throw ex resets the stack trace (so your errors would appear to originate from HandleException) throw doesn't - the original offender would be preserved.

    • 0
  • Bharathi Raja
    Jan, 2018 20

    throw ex resets the stack trace (so your errors would appear to originate from HandleException) throw doesn't - the original offender would be preserved.

    • 0
  • Bharathi Raja
    Jan, 2018 20

    throw ex resets the stack trace (so your errors would appear to originate from HandleException) throw doesn't - the original offender would be preserved.

    • 0
  • Rajani Pandey
    Jan, 2018 7

    Throw provide actual error Throw ex provide the stack trace

    • 0
  • Pradeep Yadav
    May, 2017 24

    “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.

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS