Usually we get an exception at the top level of code, such as GUI (forms).
But I usually have code like this
try
{
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
MessageBox.Show("Application has encountered error....");
}
I could just catch (exception) without an identifier, because I do not need a message at runtime, but to build debugging, of course, it’s convenient to break it down on the output. Therefore, I usually write Console.WriteLine to prevent a lot of warnings about an unused ex variable. In my code, I have many cases of Console.WriteLine (ex.Message). Does this reduce the cost?
Note. Changed the name from "Does Console.WriteLine (ex.Message) cost the execution?" to "Call Console.WriteLine (ex.Message) to prevent a warning"