admin管理员组

文章数量:1241063

Is there something like console.log in Javascript for Visual Basic?

For example, how can I do this with VB?

var monkey = "chimp"; console.log(monkey); //Logs "chimp" in the console.

Is there something like console.log in Javascript for Visual Basic?

For example, how can I do this with VB?

var monkey = "chimp"; console.log(monkey); //Logs "chimp" in the console.

Share Improve this question edited Nov 10, 2014 at 4:15 user3972104 asked Nov 10, 2014 at 3:46 EnochEnoch 2521 gold badge4 silver badges12 bronze badges 2
  • 1 Use breakpoints in Visual Studio. – David East Commented Nov 10, 2014 at 3:47
  • Console.Write or Console.WriteLine if you're building a console app. MessageBox.Show for a WinForms app. But the debugger is the best way to check values in a .NET program. You can put debugger(); in JavaScript to step into the program from IE into the Visual Studio IDE as well. – Tim Commented Nov 10, 2014 at 3:50
Add a ment  | 

1 Answer 1

Reset to default 11

It depends on the platform and application you are using and more importantly the purpose of the logging.

You can use the Console class which offers Write and WriteLine static methods. This will write your log to standard console. For a console application, this is the best choice:

System.Console.WriteLine("Log text")

If you are using the log just for debugging purposes, you can use the System.Diagnostics.Debug class with WriteLine static method. This class also offers a WriteLineIf method which accepts an argument of type Boolean and writes the log if the value passed for that argument equals to True:

System.Diagnostics.Debug.WriteLineIf(x = y, "They are equal")

You can view the debug console output in Visual Studio's output window.

本文标签: javascriptSimilar operation for Consolelog in VBNetStack Overflow