StringBuilder

A .NET class that builds text in one growable buffer, avoiding a new string for every piece appended.

In more detail

Because strings are immutable, adding to a string in a loop creates a throwaway string each time. StringBuilder appends into one buffer and produces the final string with ToString.

Example

var sb = new StringBuilder(); sb.Append(1).Append(';');

Related terms

Taught in

References