Environment.NewLine Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan string baris baru yang ditentukan untuk lingkungan ini.
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
Nilai Properti
\r\n untuk platform non-Unix, atau \n untuk platform Unix.
Contoh
Contoh berikut menampilkan dua baris yang dipisahkan oleh baris baru.
// 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
'
Keterangan
Nilai properti NewLine adalah konstanta yang disesuaikan khusus untuk platform saat ini dan implementasi .NET Framework. Untuk informasi selengkapnya tentang karakter escape dalam nilai properti, lihat Karakter Escapes.
Fungsionalitas yang disediakan oleh NewLine sering kali apa yang dimaksud dengan istilah baris baru, umpan baris, jeda baris, pengembalian gerbong, CRLF, dan akhir baris.
NewLine dapat digunakan bersama dengan dukungan baris baru khusus bahasa seperti karakter escape '\r' dan '\n' di Microsoft C# dan C/C++, atau vbCrLf di Microsoft Visual Basic.
NewLine secara otomatis ditambahkan ke teks yang Console.WriteLine diproses oleh metode dan StringBuilder.AppendLine .