http://www.dotnetperls.com/throw
In the above website, in 1st example without Console.WriteLine(ex.StackTrace); it is determine the location of the Exception. I wish to know whether Console.WriteLine(ex.StackTrace); is needed to determine the location of the Exception.
Loading
VulpesPosted Aug 2, 2013, 5:40 PM
Console.WriteLine(ex);
which is the overload of Console.WriteLine which takes an object parameter.
You may recall from a previous thread that the ToString() method is implicitly called on the object passed in and, in the case of the Exception class, this (by default) not only displays the stack trace but some other info besides. For more detail see:
http://msdn.microsoft.com/en-us/library/system.exception.tostring.aspx
So the answer to your question is that you don't necessarily need to use ex.StackTrace to determine the location of the exception - you can use ex.ToString() as well.
Posted Aug 2, 2013, 6:22 PM