StringBuilder.AppendLine 메서드

정의

이 인스턴스의 끝에 기본 줄 종결자 또는 지정한 문자열의 복사본과 기본 줄 종결자를 추가합니다.

오버로드

AppendLine()

현재 StringBuilder 개체의 끝에 기본 줄 종결자를 추가합니다.

AppendLine(String)

현재 StringBuilder 개체의 끝에 지정한 문자열의 복사본과 기본 줄 종결자를 차례로 추가합니다.

AppendLine(StringBuilder+AppendInterpolatedStringHandler)

지정 된 보간된 문자열 뒤에 기본 줄 종결자를 추가 하 여 현재 StringBuilder 개체의 끝에 추가 합니다.

AppendLine(IFormatProvider, StringBuilder+AppendInterpolatedStringHandler)

지정 된 형식을 사용 하 여 지정 된 보간된 문자열 뒤에 기본 줄 종결자를 추가 하 여 현재 StringBuilder 개체의 끝에 추가 합니다.

AppendLine()

현재 StringBuilder 개체의 끝에 기본 줄 종결자를 추가합니다.

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

반환

StringBuilder

추가 작업이 완료된 후 이 인스턴스에 대한 참조입니다.

특성

예외

이 인스턴스의 값이 커지면 MaxCapacity가 초과됩니다.

예제

다음 예제는 AppendLine 메서드.

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

설명

기본 줄 종결자는 속성의 현재 값입니다 Environment.NewLine .

이 인스턴스의 용량은 필요에 따라 조정 됩니다.

호출자 참고

.net Core 및 .NET Framework 4.0 이상 버전에서 StringBuilder 생성자를 호출 하 여 개체를 인스턴스화하면 StringBuilder(Int32, Int32) 인스턴스의 길이와 용량이 모두 StringBuilder 해당 속성의 값을 초과 하 여 커질 수 있습니다 MaxCapacity . 이는 특히 및 메서드를 호출 하 여 Append(String) 작은 문자열을 추가 하는 경우에 발생할 수 있습니다 AppendFormat(String, Object) .

추가 정보

적용 대상

AppendLine(String)

현재 StringBuilder 개체의 끝에 지정한 문자열의 복사본과 기본 줄 종결자를 차례로 추가합니다.

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

매개 변수

value
String

추가할 문자열입니다.

반환

StringBuilder

추가 작업이 완료된 후 이 인스턴스에 대한 참조입니다.

특성

예외

이 인스턴스의 값이 커지면 MaxCapacity가 초과됩니다.

설명

기본 줄 종결자는 속성의 현재 값입니다 Environment.NewLine .

이 인스턴스의 용량은 필요에 따라 조정 됩니다.

호출자 참고

.net Core 및 .NET Framework 4.0 이상 버전에서 StringBuilder 생성자를 호출 하 여 개체를 인스턴스화하면 StringBuilder(Int32, Int32) 인스턴스의 길이와 용량이 모두 StringBuilder 해당 속성의 값을 초과 하 여 커질 수 있습니다 MaxCapacity . 이는 특히 및 메서드를 호출 하 여 Append(String) 작은 문자열을 추가 하는 경우에 발생할 수 있습니다 AppendFormat(String, Object) .

추가 정보

적용 대상

AppendLine(StringBuilder+AppendInterpolatedStringHandler)

지정 된 보간된 문자열 뒤에 기본 줄 종결자를 추가 하 여 현재 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

매개 변수

handler
StringBuilder.AppendInterpolatedStringHandler

추가할 보간된 문자열입니다.

반환

StringBuilder

추가 작업이 완료된 후 이 인스턴스에 대한 참조입니다.

적용 대상

AppendLine(IFormatProvider, StringBuilder+AppendInterpolatedStringHandler)

지정 된 형식을 사용 하 여 지정 된 보간된 문자열 뒤에 기본 줄 종결자를 추가 하 여 현재 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

매개 변수

provider
IFormatProvider

문화권별 형식 정보를 제공하는 개체입니다.

handler
StringBuilder.AppendInterpolatedStringHandler

추가할 보간된 문자열입니다.

반환

StringBuilder

추가 작업이 완료된 후 이 인스턴스에 대한 참조입니다.

적용 대상