Console.WriteLine() 与 Debug.WriteLine() 有什么区别? [英] What's the difference between Console.WriteLine() vs Debug.WriteLine()?

查看:68
本文介绍了Console.WriteLine() 与 Debug.WriteLine() 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Console.WriteLine()Debug<的区别是什么代码>.WriteLine()?

推荐答案

Console.WriteLine 在调试或发布中写入标准输出流.Debug.WriteLine 写入跟踪侦听器Listeners 集合,但仅在运行时调试.在发布配置中编译应用程序时,Debug 元素不会被编译到代码中.

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.

作为 Debug.WriteLine 写入 侦听器 集合,这可能会在多个地方输出(Visual Studio 输出窗口、控制台、日志文件、注册侦听器的第三方应用程序(我相信 DebugView 会这样做),等等).

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.).

这篇关于Console.WriteLine() 与 Debug.WriteLine() 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆