What's the difference between Console.WriteLine() vs Debug.WriteLine()?

前端 未结 3 777
一个人的身影
一个人的身影 2020-12-01 00:53

What\'s the difference between Console.WriteLine() vs Debug.WriteLine()?

3条回答
  •  被撕碎了的回忆
    2020-12-01 01:22

    Console.WriteLine writes to the standard output stream, either in debug or release. Debug.WriteLine writes to the trace listeners in the Listeners collection, but only when running in debug. When the application is compiled in the release configuration, the Debug elements will not be compiled into the code.

    As Debug.WriteLine writes to all the trace listeners in the Listeners collection, it is possible that this could be output in more than one place (Visual Studio output window, Console, Log file, third-party application which registers a listener (I believe DebugView does this), etc.).

提交回复
热议问题