What are the differences between Console.Write and Console.WriteLine in C#.Net?

C#.Net: Learn what are the contrasts among Console. Write and Console.WriteLine techniques in C#.Net, why and when they are utilized?

In the last post, we have figured out how to print our first program in C#.Net? In that program we utilized Console.WriteLine() to print the message on the comfort yield screen, we

can likewise utilize Console.Write() to do likewise, we should realize what are the contrasts among Console.Write and Console.WriteLine technique in C#.Net?

Console.Write() and Console.WriteLine(), the two strategies are utilized to print information on the support screen. Here, Console is a predefined class of System namespace from Framework Class Library, Write() and WriteLine() are the strategies for the Console Class.

Console.Write()

Console.Write prints the information without printing the new line after the message.

Example of Console.Write() in C#.Net:

using System;

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

Output:

Hello World 
Press any key to continue  . . .

“Press any key to continue…” is the default message after the yield, you can find in the yield there is no newline or even space after the program Output “Hello World”.

Console.WriteLine()

Console.WriteLine strategy prints the message on the support screen just as new line character after the message.

Example of Console.WriteLine() in C#.Net:

using System;

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

Output:

Hello World
Press any key to continue  . . .

See the yield, the message “Press any key to continue…” prints after the program yield “Hello World”.

1 thought on “What are the differences between Console.Write and Console.WriteLine in C#.Net?”

  1. Pingback: What are the differences between Console.Read and Console.ReadLine in C#.Net? – JustTechReview

Leave a Comment

error: Alert: Content is protected!!