Difference Between Write and WriteLine
Table of Contents
Write Method
Write method resides inside the ‘Console’ class which itself resides inside the System namespace. The Console class provides basic support for applications that read and write characters to and from the console. The write() method outputs one or more values on the screen without a new line character. This means any subsequent output will be printed in the same line.
Example of Write() in C#
Output:
Car Bus Truck
WriteLine Method
The WriteLine method also resides inside the ‘Console’ class of the System namespace. The WriteLine method prints one or more object on a single line with a new line character inserted at the end. This means any subsequent output will be printed on a new line.
Example of WriteLine() in C#
Output:
Car
Bus
Truck
Difference Between Write and WriteLine
The Write method is used to print one or more objects on a single line without inserting a new line character at the end. The WriteLine method inserts a new line character after printing the output. In the Write method, the cursor remains at the same line, while in WriteLine it moves to the next.
ncG1vNJzZmijla6xqrLFnqmeppOawG%2BvzqZmnaGWm7Kzsc2cnGaalanEprHNZq6roaSaeqK6w2auq6GkmrmqusRnn62lnA%3D%3D