Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Similar operation for Console.log in VB.Net?

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.

like image 528
Enoch Avatar asked Dec 26 '22 02:12

Enoch


1 Answers

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.

like image 66
Alireza Avatar answered Jan 06 '23 05:01

Alireza