C# StringBuilder AppendLine(String)

Description

StringBuilder AppendLine(String) Appends a copy of the specified string followed by the default line terminator to the end of the current StringBuilder object.

Syntax

StringBuilder.AppendLine(String) has the following syntax.


[ComVisibleAttribute(false)]
public StringBuilder AppendLine(
  string value
)

Parameters

StringBuilder.AppendLine(String) has the following parameters.

  • value - The string to append.

Returns

StringBuilder.AppendLine(String) method returns A reference to this instance after the append operation has completed.

Example


/*from   ww  w . j a  v  a 2 s. c o  m*/
using System;
using System.Text;

public class Class1
{
   public static void Main()
   {
      StringBuilder sb = new StringBuilder("This is a string.");
      sb.AppendLine("This is a second string.");
      Console.WriteLine("{0} ({1} characters)", sb.ToString(), sb.Length);
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding