Environment.NewLine プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
この環境に対して定義されている改行文字列を取得します。
public:
static property System::String ^ NewLine { System::String ^ get(); };
public static string NewLine { get; }
static member NewLine : string
Public Shared ReadOnly Property NewLine As String
プロパティ値
\r\n Unix 以外のプラットフォームの場合は \n 。Unix プラットフォームの場合は 。
例
次の使用例は、改行で区切られた 2 つの行を表示します。
// 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'、または Microsoft Visual Basic の vbCrLf など、言語固有の改行のサポートと組み合わせて使用できます。
NewLine は、 Console.WriteLine および StringBuilder.AppendLine メソッドによって処理されるテキストに自動的に追加されます。