Visual Basic .NET Language Console.WriteLine()


Dim x As Int32 = 128
Console.WriteLine(x) ' Variable '
Console.WriteLine(3) ' Integer '
Console.WriteLine(3.14159) ' Floating-point number '
Console.WriteLine("Hello, world") ' String '
Console.WriteLine(myObject) ' Outputs the value from calling myObject.ToString()

The Console.WriteLine() method will print the given argument(s) with a newline attached at the end. This will print any object supplied, including, but not limited to, strings, integers, variables, floating-point numbers.

When writing objects that are not explicitly called out by the various WriteLine overloads (that is, you are using the overload that expects a value of type Object, WriteLine will use the .ToString() method to generate a String to actually write. Your custom objects should OverRide the .ToString method and produce something more meaningful than the default implementation (which typically just writes the fully qualified type name).