Open E-School

Friday, February 24, 1984

Console.Write and Console.WriteLine methods in C#

Category: Programming Date: Thursday, March 19, 2015
OpenESchool Emagazine


Learn about Console.Write() and Console.WriteLine() methods in C# and how to use them in your program

Namespaces used:

  1. System ?- Console class is defined in the System namespace

Classes used:

  1. Console - It contains all the methods required to interact with the Console window

Methods used:

  1. Write() – Static method in the Console class
  2. WriteLine() – Static method in the Console class

Brief description: ?

Console.Write: Displays the output to the console screen and keeps the cursor on the same line.
Console.WriteLine: Writes the output on the console screen and takes the cursor to the next line automatically. Console.WriteLine(“Hello”) is equivalent to Console.Write(“Hello ”)


using System;    namespace ConsoleApplication1  {      class Program      {          public static void Main(string[] args)          {              Console.Write("Line 1 written using Console.Write ()");              Console.Write("Line 2 written using Console.Write ()");                Console.Write("


");                Console.WriteLine("Line 1 written using Console.WriteLine ()");              Console.WriteLine("Line 2 written using Console.WriteLine ()");          }      }  }


Console.Write() and Console.WriteLine() in C#

Explanation of the output

?In the output we see that Console.Write() method does not take the cursor to the next line automatically and prints both the line1 and line2 in the same line. Whereas you see that Console.WriteLine() takes the cursor to the next line automatically and prints both line1 and line2 in separate lines

Rate this article and help us improve

Please Login to rate
Overall ratings: 0 | Rating: out of 5
Previous Article Next Article

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp