Using the Console

Writing to the Console using Console.Write

The big difference between Console.WriteLine and Console.Write is that WriteLine adds a line terminator to whatever you have written. But when you are using the Write method, if you want to move the output to the next line, you need to manually add a line terminator yourself to break the line into multiple lines.

using System; public class Program { ...


You'll notice in our interactive example, we're using the Environment.NewLine property. This provides the new line character combintation, which is dependent on the platform of your choosing. Most Unix operating systems rely on "\n" which is 'line-feed', Windows-based operating systems use "\r\n" which is 'carriage-return/line-feed'. As a best practice, always prefer to use the Environment.NewLine property when handling new line operations.

Using Console.Write gives you more control over how you want your output written to the Console.

Page 5 of 12