The Console.WriteLine()
and Console.Write()
methods print values or texts to the console. The Console.WriteLine()
method prints a new line after the text or a value. The Console.Write()
method only prints the text or value without a new line.
Console.WriteLine(value)Console.Write(value)
value:
This can be a text or a value.
value
is returned or printed to the console.
Console.Write()
using System;class HelloWorld {static void Main() {Console.Write("Hello");Console.Write(" and welcome ");Console.Write("to ");Console.Write("Edpresso!");}}
Console.Write()
method. When we run it, we discover that the values are printed without a new line.Console.WriteLine()
using System;class HelloWorld {static void Main() {Console.WriteLine("Hello");Console.WriteLine("and welcome ");Console.WriteLine("to");Console.WriteLine("Edpresso!");}}
Console.WriteLine()
method. When we run it, we discover that the values are printed with new lines.