System.Environment.NewLine Property

Gets the newline string defined for this environment.

Syntax

public static string NewLine { get; }

Value

A string containing the characters required to write a newline.

Remarks

The property value of Environment.NewLine is a constant customized specifically for the current platform and implementation of the .NET Framework. For more information about the escape characters in the property value, see Character Escapes.

The functionality provided by Environment.NewLine is often what is meant by the terms newline, line feed, line break, carriage return, CRLF, and end of line.

Environment.NewLine can be used in conjunction with language-specific newline support such as the escape characters '\r' and '\n' in Microsoft C# and C/C++, or vbCrLf in Microsoft Visual Basic.

Environment.NewLine is automatically appended to text processed by the erload:System.Console.WriteLine and erload:System.Text.StringBuilder.AppendLine methods.

Example

The following example demonstrates using the Environment.NewLine property. The string returned by Environment.NewLine is inserted between "Hello" and "World", causing a line break between the words in the output.

C# Example

using System;
class TestClass {
    public static void Main() {
      Console.WriteLine("Hello,{0}World",
                        Environment.NewLine);
    }
}

The output is

Hello,
World

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0