StringBuilder.AppendLine Metoda

Definicja

Dołącza domyślny terminator wiersza lub kopię określonego ciągu i domyślnego terminatora wiersza na końcu tego wystąpienia.

Przeciążenia

AppendLine()

Dołącza domyślny terminator wiersza na końcu bieżącego StringBuilder obiektu.

AppendLine(String)

Dołącza kopię określonego ciągu, po którym następuje domyślny terminator wiersza na końcu bieżącego StringBuilder obiektu.

AppendLine(StringBuilder+AppendInterpolatedStringHandler)

Dołącza określony ciąg interpolowany, po którym następuje domyślny terminator wiersza na końcu bieżącego obiektu StringBuilder.

AppendLine(IFormatProvider, StringBuilder+AppendInterpolatedStringHandler)

Dołącza określony ciąg interpolowany przy użyciu określonego formatu, po którym następuje domyślny terminator wiersza, na końcu bieżącego obiektu StringBuilder.

AppendLine()

Dołącza domyślny terminator wiersza na końcu bieżącego StringBuilder obiektu.

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

Zwraca

StringBuilder

Odwołanie do tego wystąpienia po zakończeniu operacji dołączania.

Atrybuty

Wyjątki

Zwiększenie wartości tego wystąpienia przekroczy wartość MaxCapacity .

Przykłady

W poniższym przykładzie pokazano AppendLine metodę .

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

using namespace System;
using namespace System::Text;

int main()
{
    StringBuilder^ sb = gcnew StringBuilder;
    String^ line = L"A line of text.";
    int number = 123;

    // Append two lines of text.
    sb->AppendLine( L"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( L"" );
    sb->AppendLine( L"" );

    // 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( L"The last line of text." );

    // Convert the value of the StringBuilder to a string and display the string.
    Console::WriteLine( sb );

    return 0;
}

/*
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.

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.
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.

Uwagi

Domyślny terminator wiersza jest bieżącą wartością Environment.NewLine właściwości.

Pojemność tego wystąpienia jest dostosowywana odpowiednio do potrzeb.

Uwagi dotyczące wywoływania

W programie .NET Core i w wersji .NET Framework 4.0 i nowszych podczas tworzenia wystąpienia obiektu przez wywołanie konstruktora zarówno długość, jak i pojemność wystąpienia mogą przekroczyć wartość jego StringBuilder StringBuilder(Int32, Int32) StringBuilder MaxCapacity właściwości. Może się to zdarzyć szczególnie w przypadku wywołania metod Append(String) i AppendFormat(String, Object) w celu dołączania małych ciągów.

Zobacz też

Dotyczy

AppendLine(String)

Dołącza kopię określonego ciągu, po którym następuje domyślny terminator wiersza na końcu bieżącego StringBuilder obiektu.

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

Ciąg, który ma być dołączony.

Zwraca

StringBuilder

Odwołanie do tego wystąpienia po zakończeniu operacji dołączania.

Atrybuty

Wyjątki

Zwiększenie wartości tego wystąpienia przekroczy wartość MaxCapacity .

Uwagi

Domyślny terminator wiersza jest bieżącą wartością Environment.NewLine właściwości.

Pojemność tego wystąpienia jest dostosowywana odpowiednio do potrzeb.

Uwagi dotyczące wywoływania

W programie .NET Core i w wersji .NET Framework 4.0 i nowszych podczas tworzenia wystąpienia obiektu przez wywołanie konstruktora zarówno długość, jak i pojemność wystąpienia mogą przekroczyć wartość jego StringBuilder StringBuilder(Int32, Int32) StringBuilder MaxCapacity właściwości. Może się to zdarzyć szczególnie w przypadku wywołania metod Append(String) i AppendFormat(String, Object) w celu dołączania małych ciągów.

Zobacz też

Dotyczy

AppendLine(StringBuilder+AppendInterpolatedStringHandler)

Dołącza określony ciąg interpolowany, po którym następuje domyślny terminator wiersza na końcu bieżącego obiektu StringBuilder.

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

Ciąg interpolowany do dołączyć.

Zwraca

StringBuilder

Odwołanie do tego wystąpienia po zakończeniu operacji dołączania.

Dotyczy

AppendLine(IFormatProvider, StringBuilder+AppendInterpolatedStringHandler)

Dołącza określony ciąg interpolowany przy użyciu określonego formatu, po którym następuje domyślny terminator wiersza, na końcu bieżącego obiektu 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

Obiekt, który dostarcza informacje o formatowaniu specyficzne dla kultury.

handler
StringBuilder.AppendInterpolatedStringHandler

Ciąg interpolowany do dołączyć.

Zwraca

StringBuilder

Odwołanie do tego wystąpienia po zakończeniu operacji dołączania.

Dotyczy