Environment.NewLine Tulajdonság

Definíció

Lekéri a környezethez definiált újvonalas sztringet.

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

Tulajdonság értéke

\r\n nem Unix-platformokhoz vagy \n Unix-platformokhoz.

Példák

Az alábbi példában két sor látható, amelyeket egy új vonal választ el egymástól.

// 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
'

Megjegyzések

A NewLine tulajdonságértéke a .NET-keretrendszer aktuális platformjára és implementálására szabott állandó. A tulajdonságérték feloldó karaktereiről további információt a Karaktermenekülések című témakörben talál.

Az új vonal, a vonalcsatorna, a vonaltörés, a kocsivisszaadás, a CRLF és a sor vége kifejezések gyakran az általuk biztosított NewLine funkciókat jelentik.

A NewLine olyan nyelvspecifikus újvonalas támogatással együtt használható, mint a Microsoft C# és C/C++ fájlban a "\r" és "\n", vagy vbCrLf Microsoft Visual Basic.

NewLine a program automatikusan hozzáfűzi a metódusok által feldolgozott szöveghez Console.WriteLineStringBuilder.AppendLine .

A következőre érvényes: