StringBuilder.AppendLine 메서드

정의

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

오버로드

Name Description
AppendLine()

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

AppendLine(String)

지정된 문자열의 복사본을 추가한 다음 기본 줄 종결자를 현재 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

반품

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

특성

예외

이 인스턴스의 값을 확대하면 을 초과 MaxCapacity합니다.

예제

다음 예제에서는 메서드를 보여 줍니다 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.

설명

기본 줄 종결자는 속성의 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);
[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

추가할 문자열입니다.

반품

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

특성

예외

이 인스턴스의 값을 확대하면 을 초과 MaxCapacity합니다.

설명

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

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

호출자 참고

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

추가 정보

적용 대상