Environment.NewLine 属性  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取为此环境定义的换行字符串。
public:
 static property System::String ^ NewLine { System::String ^ get(); };public static string NewLine { get; }member this.NewLine : stringPublic Shared ReadOnly Property NewLine As String属性值
\r\n 对于非 Unix 平台或 \n Unix 平台。
示例
以下示例显示用换行符分隔的两行。
// Sample for the Environment::NewLine property
using namespace System;
int main()
{
   Console::WriteLine();
   Console::WriteLine("NewLine: {0}  first line {0}  second line", Environment::NewLine);
}
/*
This example produces the following results:
NewLine:
first line
second line
*/
// Sample for the Environment.NewLine property
using System;
class Sample
{
    public static void Main()
    {
        Console.WriteLine();
        Console.WriteLine($"NewLine: {Environment.NewLine}  first line{Environment.NewLine}  second line");
    }
}
/*
This example produces the following results:
NewLine:
  first line
  second line
*/
// Sample for the Environment.NewLine property
open System
printfn $"\nNewLine: {Environment.NewLine}  first line{Environment.NewLine}  second line"
// This example produces the following results:
//     NewLine:
//       first line
//       second line
' Sample for the Environment.NewLine property
Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      Console.WriteLine($"NewLine:{Environment.NewLine}  first line{Environment.NewLine}  second line")
   End Sub
End Class
'This example produces the following results:
'
'NewLine:
'  first line
'  second line
'
注解
属性值NewLine是针对当前平台和.NET Framework实现进行自定义的常量。 有关属性值中的转义字符的详细信息,请参阅 字符转义。
提供 NewLine 的功能通常是换行符、换行符、换行符、回车符、CRLF 和行尾术语的含义。
NewLine可与特定于语言的新行支持结合使用,例如 Microsoft C# 和 C/C++ 中的转义字符“\r”和“\n”,也可以在 vbCrLf Microsoft Visual Basic中使用。
NewLine 自动追加到由 Console.WriteLine 和 StringBuilder.AppendLine 方法处理的文本。