Environment.NewLine in C#


The Enviornment.NewLine in C# is used to add newline.

To set a new line in between words −

str = "This is demo text!" + Environment.NewLine + "This is demo text on next line!";

The following is the code −

Example

 Live Demo

using System;
using System.IO;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         string str = "This is demo text!" + Environment.NewLine + "This is demo text on next line!";
         Console.Write(str);
      }
   }
}

Output

This is demo text!
This is demo text on next line!

Updated on: 22-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements