Sdílet prostřednictvím


StringBuilder.AppendLine Metoda

Definice

Připojí výchozí ukončovací znak řádku nebo kopii zadaného řetězce a výchozí ukončovací znak řádku na konec této instance.

Přetížení

Name Description
AppendLine()

Připojí výchozí ukončovací znak řádku na konec aktuálního StringBuilder objektu.

AppendLine(String)

Připojí kopii zadaného řetězce následovanou výchozím ukončovacím znakem řádku na konec aktuálního StringBuilder objektu.

AppendLine(StringBuilder+AppendInterpolatedStringHandler)

Připojí zadaný interpolovaný řetězec následovaný výchozím ukončovacím znakem řádku na konec aktuálního StringBuilder objektu.

AppendLine(IFormatProvider, StringBuilder+AppendInterpolatedStringHandler)

Připojí zadaný interpolovaný řetězec pomocí zadaného formátu následovaného výchozím ukončovacím znakem řádku na konec aktuálního objektu StringBuilder.

AppendLine()

Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs

Připojí výchozí ukončovací znak řádku na konec aktuálního StringBuilder objektu.

public:
 System::Text::StringBuilder ^ AppendLine();
public System.Text.StringBuilder AppendLine();
[System.Runtime.InteropServices.ComVisible(false)]
public System.Text.StringBuilder AppendLine();
member this.AppendLine : unit -> System.Text.StringBuilder
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.AppendLine : unit -> System.Text.StringBuilder
Public Function AppendLine () As StringBuilder

Návraty

Odkaz na tuto instanci po dokončení operace připojení.

Atributy

Výjimky

Zvětšení hodnoty této instance by překročilo MaxCapacity.

Příklady

Následující příklad ukazuje metodu AppendLine .

// This example demonstrates the StringBuilder.AppendLine()
// method.

using System;
using System.Text;

class Sample
{
    public static void Main()
    {
    StringBuilder sb = new StringBuilder();
    string        line = "A line of text.";
    int           number = 123;

// Append two lines of text.
    sb.AppendLine("The first line of text.");
    sb.AppendLine(line);

// Append a new line, an empty string, and a null cast as a string.
    sb.AppendLine();
    sb.AppendLine("");
    sb.AppendLine((string)null);

// Append the non-string value, 123, and two new lines.
    sb.Append(number).AppendLine().AppendLine();

// Append two lines of text.
    sb.AppendLine(line);
    sb.AppendLine("The last line of text.");

// Convert the value of the StringBuilder to a string and display the string.
    Console.WriteLine(sb.ToString());
    }
}
/*
This example produces the following results:

The first line of text.
A line of text.



123

A line of text.
The last line of text.
*/
// This example demonstrates the StringBuilder.AppendLine()
// method.

open System.Text

let sb = StringBuilder()
let line = "A line of text."
let number = 123

// Append two lines of text.
sb.AppendLine "The first line of text." |> ignore
sb.AppendLine line |> ignore

// Append a new line, an empty string, and a null cast as a string.
sb.AppendLine() |> ignore
sb.AppendLine "" |> ignore
sb.AppendLine Unchecked.defaultof<string> |> ignore

// Append the non-string value, 123, and two new lines.
sb.Append(number).AppendLine().AppendLine() |> ignore

// Append two lines of text.
sb.AppendLine line |> ignore
sb.AppendLine "The last line of text." |> ignore

// Convert the value of the StringBuilder to a string and display the string.
printfn $"{sb}"

// This example produces the following results:
//       The first line of text.
//       A line of text.
//
//
//
//       123
//
//       A line of text.
//       The last line of text.
' This example demonstrates the StringBuilder.AppendLine() 
' method.
Imports System.Text

Class Sample
   Public Shared Sub Main()
      Dim sb As New StringBuilder()
      Dim line As String = "A line of text."
      Dim number As Integer = 123
      
      ' Append two lines of text.
      sb.AppendLine("The first line of text.")
      sb.AppendLine(line)
      
      ' Append a new line, an empty string, and a null cast as a string.
      sb.AppendLine()
      sb.AppendLine("")
      sb.AppendLine(CStr(Nothing))
      
      ' Append the non-string value, 123, and two new lines.
      sb.Append(number).AppendLine().AppendLine()
      
      ' Append two lines of text.
      sb.AppendLine(line)
      sb.AppendLine("The last line of text.")
      
      ' Convert the value of the StringBuilder to a string and display the string.
      Console.WriteLine(sb.ToString())
   End Sub
End Class
'
'This example produces the following results:
'
'The first line of text.
'A line of text.
'
'
'
'123
'
'A line of text.
'The last line of text.

Poznámky

Výchozí ukončovací znak řádku je aktuální hodnota Environment.NewLine vlastnosti.

Kapacita této instance se podle potřeby upraví.

Poznámky pro volající

V .NET Core a v rozhraní .NET Framework 4.0 a novějších verzích při vytváření instance StringBuilder objektu voláním StringBuilder(Int32, Int32) konstruktoru může délka i kapacita StringBuilder instance růst nad hodnotu jeho MaxCapacity vlastnosti. K tomu může dojít zejména při volání Append(String) a AppendFormat(String, Object) metod pro připojení malých řetězců.

Viz také

Platí pro

AppendLine(String)

Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs

Připojí kopii zadaného řetězce následovanou výchozím ukončovacím znakem řádku na konec aktuálního StringBuilder objektu.

public:
 System::Text::StringBuilder ^ AppendLine(System::String ^ value);
public System.Text.StringBuilder AppendLine(string value);
public System.Text.StringBuilder AppendLine(string? value);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Text.StringBuilder AppendLine(string value);
member this.AppendLine : string -> System.Text.StringBuilder
[<System.Runtime.InteropServices.ComVisible(false)>]
member this.AppendLine : string -> System.Text.StringBuilder
Public Function AppendLine (value As String) As StringBuilder

Parametry

value
String

Řetězec, který se má připojit.

Návraty

Odkaz na tuto instanci po dokončení operace připojení.

Atributy

Výjimky

Zvětšení hodnoty této instance by překročilo MaxCapacity.

Poznámky

Výchozí ukončovací znak řádku je aktuální hodnota Environment.NewLine vlastnosti.

Kapacita této instance se podle potřeby upraví.

Poznámky pro volající

V .NET Core a v rozhraní .NET Framework 4.0 a novějších verzích při vytváření instance StringBuilder objektu voláním StringBuilder(Int32, Int32) konstruktoru může délka i kapacita StringBuilder instance růst nad hodnotu jeho MaxCapacity vlastnosti. K tomu může dojít zejména při volání Append(String) a AppendFormat(String, Object) metod pro připojení malých řetězců.

Viz také

Platí pro

AppendLine(StringBuilder+AppendInterpolatedStringHandler)

Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs

Připojí zadaný interpolovaný řetězec následovaný výchozím ukončovacím znakem řádku na konec aktuálního StringBuilder objektu.

public:
 System::Text::StringBuilder ^ AppendLine(System::Text::StringBuilder::AppendInterpolatedStringHandler % handler);
public System.Text.StringBuilder AppendLine(ref System.Text.StringBuilder.AppendInterpolatedStringHandler handler);
member this.AppendLine : AppendInterpolatedStringHandler -> System.Text.StringBuilder
Public Function AppendLine (ByRef handler As StringBuilder.AppendInterpolatedStringHandler) As StringBuilder

Parametry

handler
StringBuilder.AppendInterpolatedStringHandler

Interpolovaný řetězec, který se má připojit.

Návraty

Odkaz na tuto instanci po dokončení operace připojení.

Platí pro

AppendLine(IFormatProvider, StringBuilder+AppendInterpolatedStringHandler)

Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs
Zdroj:
StringBuilder.cs

Připojí zadaný interpolovaný řetězec pomocí zadaného formátu následovaného výchozím ukončovacím znakem řádku na konec aktuálního objektu StringBuilder.

public:
 System::Text::StringBuilder ^ AppendLine(IFormatProvider ^ provider, System::Text::StringBuilder::AppendInterpolatedStringHandler % handler);
public System.Text.StringBuilder AppendLine(IFormatProvider? provider, ref System.Text.StringBuilder.AppendInterpolatedStringHandler handler);
member this.AppendLine : IFormatProvider * AppendInterpolatedStringHandler -> System.Text.StringBuilder
Public Function AppendLine (provider As IFormatProvider, ByRef handler As StringBuilder.AppendInterpolatedStringHandler) As StringBuilder

Parametry

provider
IFormatProvider

Objekt, který poskytuje informace o formátování specifické pro jazykovou verzi.

handler
StringBuilder.AppendInterpolatedStringHandler

Interpolovaný řetězec, který se má připojit.

Návraty

Odkaz na tuto instanci po dokončení operace připojení.

Platí pro