C# StringBuilder AppendLine()

Description

StringBuilder AppendLine() Appends the default line terminator to the end of the current StringBuilder object.

Syntax

StringBuilder.AppendLine() has the following syntax.


[ComVisibleAttribute(false)]
public StringBuilder AppendLine()

Returns

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

Example

The following example demonstrates the AppendLine method.


using System;/* w ww  .j  a  v a  2s .com*/
using System.Text;

class Sample 
{
    public static void Main() 
    {
        StringBuilder sb = new StringBuilder();
        string        line = "A line of text.";
        int           number = 123;
    
        sb.AppendLine("The first line of text.");
        sb.AppendLine(line);
    
        Console.WriteLine(sb.ToString());
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Text »




ASCIIEncoding
Encoding
EncodingInfo
StringBuilder
UnicodeEncoding
UTF8Encoding