What is the Purpose of Console.WriteLine() in Winforms

前端 未结 4 1382
终归单人心
终归单人心 2021-02-08 11:12

I once saw the source code of a winform application and the code had a Console.WriteLine();. I asked the reason for that and i was told that it was for

4条回答
  •  深忆病人
    2021-02-08 11:58

    It wouldn't perform anything unless the Console was redirected to say the Output window. Really, they should be leveraging Debug.WriteLine instead.

    The benefit of Debug.WriteLine is that it gets optimized away when building in Release mode.

    NOTE: as pointed out by Brad Christie and Haedrian, apparently it will in fact write to the Console window in Visual Studio when running a Windows Forms application. You learn something new every day!

提交回复
热议问题