Home »
.Net »
C# Programs
C# Console.Write() and Console.WriteLine() Example
C# | Console.Write() and Console.WriteLine(): In this tutorial, we will learn about the Console.Write() and Console.WriteLine() methods, their usages, syntaxes, and examples with the help of C# program.
By IncludeHelp Last updated : April 15, 2023
C# Console.Write() and Console.WriteLine() Methods
The both Console.Write() and Console.WriteLine() methods are used to print the text (values) on the Console. The Console.Write() prints only the text, whereas, Console.WriteLine() prints a new line after printing the text.
Console.Write() Method Syntax
public static void Write(string format, object? arg0, ...);
Console.WriteLine() Method Syntax
public static void WriteLine(string format, object? arg0, ...);
Read also: C# Console.WriteLine() Vs Console.Write()
C# Example of Console.Write() and Console.WriteLine()
// 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
C# Basic Programs »