There are various method to print a new line within the message
- By using: \n – It prints new line.
- By using: \x0A or \xA (ASCII literal of \n) – It prints new line.
- By using: Console.WriteLine() – It prints new line.
Examples:
Input : GeeksForGeeks
Output : Geeksfor
Geeks
Input : Save World
Output: Save
World
Below is the implementation of the above approach:
Example 1:
using System;
using System.IO;
using System.Text;
namespace geeks
{
class GFG
{
static void Main( string [] args)
{
Console.WriteLine( "Geeksfor\nGeeks" );
Console.WriteLine( "Geeks\x0A ForGeeks" );
}
}
}
|
Output:
Geeksfor
Geeks
Geeks
ForGeeks
Example 2:
using System;
using System.IO;
using System.Text;
namespace geeks
{
class GFG
{
static void Main( string [] args)
{
Console.WriteLine( "Print a new line" );
Console.WriteLine();
Console.WriteLine( "Save\nWorld" );
Console.WriteLine( "Stay\x0ASafe" );
Console.ReadLine();
}
}
}
|
Output:
Print a new line
Save
World
Stay
Safe