Exception's ToString() method

c#, resharper, tostring

Solution

If the exception is being used within a string... For example `"something" + exception.ToString()` or `String.Format("... {0}", exception)`, then yes, `ToString` will be called without you having to call it explicitly.

And... as you updated your example, calling `Console.WriteLine()` against any object value, `ToString` will be called. Here's the documentation, with as much detail as you could possibly want.

Problem

I found in someones code following : ``` catch (Exception exception) { Console.WriteLine(exception.ToString()); } ``` Resharper is graying out the `ToString()` call which is as always a great suggestion. How does this C# code work without it ? Will `ToString()` be called implicitly ?

Original source