Bertie Wheen
Bertie Wheen

Reputation: 1243

Is this simple VB.NET code valid?

So I made this and someone has submitted a new VB.NET hello world example:

Module m1
Sub Main()
 Console.out.writeline("Hello World")
End Sub
End Module

Is this valid VB.NET? I don't know the language, so wanted to check it.

The example that is currently on the website is:

Console.WriteLine ("Hello, World!")

What I'm mainly questioning is the Console.out.writeline - is this right?

Thanks in advance. :)

Upvotes: 2

Views: 130

Answers (2)

JDB
JDB

Reputation: 25810

Yes, this is correct. Console.WriteLine and Console.Out.WriteLine are equivalent.

The documentation for Console.WriteLine says: "Writes the specified string value, followed by the current line terminator, to the standard output stream."

The documentation for Console.Out says: "Gets the standard output stream."

Console.Out is a TextWriter which is used for outputting text to a stream. The documentation for TextWriter.WriteLine says: "Writes a string followed by a line terminator to the text string or stream."

Console.WriteLine is basically just a shortcut for Console.Out.WriteLine.

Upvotes: 6

embedded.kyle
embedded.kyle

Reputation: 11466

They are equivalent. Though the the Console.Out property can be set to a stream other than the standard output.

From MSDN:

This property is set to the standard output stream by default. This property can be set to another stream with the SetOut method.

Note that calls to Console.Out.WriteLine methods are equivalent to calls to the corresponding WriteLine methods.

Upvotes: 1

Related Questions