Home » C# » C# programs » C# basic programs

C# program to demonstrate example of Console.Write() and Console.WriteLine()

C# program to demonstrate example of Console.WriteLine() and Console.Write() – Here, we will print the text using both of the functions.
Submitted by IncludeHelp, on April 06, 2019

Console.Write() and Console.WriteLine() methods are used to print the text (values) on the Console. Console.Write() prints only the text, while Console.WriteLine() prints a new line after the text.

Read more: Difference between Console.WriteLine() and Console.Write() in C#

Example:

// C# program to demonstrate example of 
// Console.Write() and Console.WriteLine()
using System;
using System.IO;
using System.Text;

namespace IncludeHelp
{
    class Test
    {
        // Main Method 
        static void Main(string[] args)
        {

            Console.WriteLine("This is line1"); 
            Console.WriteLine("This is line2");
            Console.Write("This is line3");
            Console.Write("This is line4");            
            
            //hit ENTER to exit the program
            Console.ReadLine();
        }
    }
}

Output

This is line1
This is line2
This is line3This is line4





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.