次の方法で共有


Environment.NewLine プロパティ

この環境で定義されている改行文字列を取得します。

Public Shared ReadOnly Property NewLine As String
[C#]
public static string NewLine {get;}
[C++]
public: __property static String* get_NewLine();
[JScript]
public static function get NewLine() : String;

プロパティ値

"\r\n" を格納している文字列。

解説

このプロパティの値は、現在のプラットフォームに合わせてカスタマイズされた定数になります。

この値は、 WriteLine メソッドを Console.WriteLine のように使用すると、テキストに自動的に追加されます。

使用例

 
' Sample for the Environment.NewLine property
Imports System

Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      Console.WriteLine("NewLine: {0}  first line{0}  second line{0}  third line", _
                             Environment.NewLine)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'NewLine:
'  first line
'  second line
'  third line
'

[C#] 
// Sample for the Environment.NewLine property
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine();
    Console.WriteLine("NewLine: {0}  first line{0}  second line{0}  third line",
                          Environment.NewLine);
    }
}
/*
This example produces the following results:

NewLine:
  first line
  second line
  third line
*/

[C++] 
// Sample for the Environment::NewLine property
#using <mscorlib.dll>

using namespace System;

int main() {
   Console::WriteLine();
   Console::WriteLine(S"NewLine: {0}  first line {0}  second line {0}  third line",
      Environment::NewLine);
}
/*
This example produces the following results:

NewLine:
first line
second line
third line
*/

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, Common Language Infrastructure (CLI) Standard

参照

Environment クラス | Environment メンバ | System 名前空間