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:
// C# program to print a new line using System; using System.IO; using System.Text; namespace geeks { class GFG { // Main Method static void Main(string[] args) { // by using \n Console.WriteLine("Geeksfor\nGeeks"); // by using \x0A Console.WriteLine("Geeks\x0A ForGeeks"); } } } |
chevron_right
filter_none
Output:
Geeksfor Geeks Geeks ForGeeks
Example 2:
// C# program to print a new line using System; using System.IO; using System.Text; namespace geeks { class GFG { // Main Method static void Main(string[] args) { Console.WriteLine("Print a new line"); // print only next line Console.WriteLine(); // by using \n Console.WriteLine("Save\nWorld"); // by using \x0A Console.WriteLine("Stay\x0ASafe"); // ENTER to exit the program Console.ReadLine(); } } } |
chevron_right
filter_none
Output:
Print a new line Save World Stay Safe
Recommended Posts:
- How to Execute C# Program on cmd (command-line)?
- C# | Copying the elements of ArrayList to a new array
- C# | Adding new node or value at the start of LinkedList<T>
- C# | Adding new node or value at the end of LinkedList<T>
- C# | Insert a new entry in OrderedDictionary with specified key and value
- C# | Command Line Arguments
- C# Program to print all permutations of a given string
- Program to print half Diamond star pattern
- Program to Print Backslash () in C#
- Program to Input Weekday Number and Print the Weekday in C#
- Hello World Program : First program while learning Programming
- Different Ways to Take Input and Print a Float Value in C#
- Program to convert Byte array to IP Address
- C# Program for Naive algorithm for Pattern Searching
- C# Program for KMP Algorithm for Pattern Searching
- C# Program for Count Inversions in an array | Set 1 (Using Merge Sort)
- C# Program for Median of two sorted arrays of same size
- C# Program for Activity Selection Problem | Greedy Algo-1
- C# Program for Subset Sum Problem | DP-25
- C# Program for Dijkstra's shortest path algorithm | Greedy Algo-7
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

