ExtensionMethod.NET Home of 875 C#, Visual Basic, F# and Javascript extension methods

AppendLine (overrride)

Adds an override to the System.Text.StringBuilder AppendLine method which takes a second parameter so can be used like AppendFormat but also creates a new line.

Source

public static StringBuilder AppendLine(this StringBuilder sb, string format, params object[] arguments)
{
    string value = String.Format(format, arguments);
    sb.AppendLine(value);
    return sb;
}

Example

StringBuilder myStringBuilder = new StringBuilder();
myStringBuilder.AppendLine("This is the first line");
myStringBuilder.AppendLine("This is the {0} line", "second");

Author: Robin Norton

Submitted on: 19 mei 2015

Language: C#

Type: System.Text.StringBuilder

Views: 5386