Difference between throw; & throw ex; | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Difference between throw; & throw ex;

could anyone simple explain mentioned difference between throw and throw ex? i know that its connected with stack trace. thanks

31st May 2017, 12:50 PM
Mateusz Byczkowski
Mateusz Byczkowski - avatar
1 Resposta
+ 1
"throw ex throwsĀ the sameĀ exception, but resets the stack trace to that method. Unless you want to reset the stack trace (i.e. to shield public callers from the internal workings of your library),Ā throwĀ is generally the better choice, since you can see where theĀ exceptionĀ originated." https://stackoverflow.com/questions/730250/is-there-a-difference-between-throw-and-throw-ex
31st May 2017, 2:48 PM
Eranga
Eranga - avatar