Console.WriteLine renders a line of text on the console. It is a useful Console method. In its simplest form it outputs the string argument with a trailing newline. With no arguments it outputs a blank line.

Example. First, there are many overloads on Console.WriteLine. An overloaded method has the same name but accepts different parameters. The overload can have different types of parameters, different numbers of parameters, or both.

It is helpful to know that when you use the Console class, you do not need to create a new Console(). You need to add the "using System" line at the start. WriteLine is a static method on the Console type.

Alternatively: You can specify System.Console.WriteLine() to reference the namespace directly.

Empty line. Next, it is possible to use Console.WriteLine with no arguments. This will simply output a blank line to the Console window. This is an elegant way to output an empty line. You do not have to specify the newline character.

Format strings. In some programs, you will want to write several values on a single line to the Console. One way you can do this is by appending the string using the + operator before passing it to Console.WriteLine.

The example C# code will print the words "Dot, Net, Perls" to the Console. The commas in the format string are retained and printed unchanged. Please remember to start counting at 0 for the format string substitution markers.

Same line. You can combine the Console.Write method with the Console.WriteLine method. Both methods can be used on the same line. Write does not append a newline to the end. A detailed example of Console.Write is available.

Colors. You can combine Console.Write and WriteLine with Console coloring. This can really enhance the usability of your console programs. Other methods, such as Clear, can really make your life easier.

Summary. We saw several overloads for the Console.WriteLine method. This method is used in many terminal programs. It lets you display diagnostic messages even in Release mode. Along with Console.Write, it is essential to console applications.

Tip: You can add a Shortcut to your program. This allows you to run your program from the desktop icon.