vb.net VB.Net中Console.log的类似操作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26836402/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Similar operation for Console.log in VB.Net?
提问by Enoch
Is there something like console.log in Javascript for Visual Basic?
Visual Basic 的 Javascript 中是否有类似于 console.log 的东西?
For example, how can I do this with VB?
例如,我怎样才能用 VB 做到这一点?
var monkey = "chimp"; console.log(monkey); //Logs "chimp" in the console.
varmonkey = "黑猩猩"; 控制台日志(猴子);//在控制台中记录“黑猩猩”。
回答by Alireza
It depends on the platform and application you are using and more importantly the purpose of the logging.
这取决于您使用的平台和应用程序,更重要的是日志记录的目的。
You can use the Consoleclass which offers Writeand WriteLinestatic methods. This will write your log to standard console. For a console application, this is the best choice:
您可以使用Console类报价Write和WriteLine静态方法。这会将您的日志写入标准控制台。对于控制台应用程序,这是最佳选择:
System.Console.WriteLine("Log text")
If you are using the log just for debugging purposes, you can use the System.Diagnostics.Debugclass with WriteLinestatic method. This class also offers a WriteLineIfmethod which accepts an argument of type Booleanand writes the log if the value passed for that argument equals to True:
如果您仅将日志用于调试目的,则可以使用System.Diagnostics.Debug带有WriteLine静态方法的类。此类还提供了一种WriteLineIf方法,该方法接受类型参数Boolean并在为该参数传递的值等于 时写入日志True:
System.Diagnostics.Debug.WriteLineIf(x = y, "They are equal")
You can view the debug console output in Visual Studio's output window.
您可以在 Visual Studio 的输出窗口中查看调试控制台输出。

