Using Console.Write and Console.WriteLine functions in C#

In the previous program we wrote a console application to print Hello World string like this

Hello world console application using C#
 
Here you might see that the output does not look very neat and clean. See how two sentences have got mixed together. You might want that the Hello World sentence is printed in the first line and the Press any key to continue… sentence should be printed in the next like. To do this you have two options.

1)    Put after Hello World. By using you are asking the program to go to the next line after printing Hello World

Console.Write(“Hello World! 
”);


2)    Use Console.WriteLine function in place of Console.Write function. This will automatically take the cursor to the next line after printing Hello World

Console.WriteLine(“Hello World”);

The better option out of the above two options is to use the Console.WriteLine function. Look at this code

class Program  {          static void Main(string[] args)          {              Console.WriteLine("Hello World");          }  }

We have used Console.WriteLine function in this program.The output of this program will be like this

Hello world console project using C#
 

Quick Links

E-Magazines

@

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..

Ok

Login to Open ESchool OR Create your account    Login   SignUp