System.Text.StringBuilder

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
namespace System.Text
public class StringBuilder

The System.Text.StringBuilder class provides a set of methods to manipulate a mutable string of characters and modify a string without creating a new object. Since string objects are immutable (once assigned, they can’t be changed), if one is modified, a new string object must be created, causing overhead and other issues. Because the StringBuilder class provides an optimized way to deal with these operations, it’s useful for repetitive string operations. If you need to concatenate multiple strings together in a loop, using StringBuilder can help improve performance.

Constructors

StringBuilder

public StringBuilder()

Initializes a new instance of the StringBuilder class.

or

public StringBuilder(capacity)

Initializes a new instance of the StringBuilder class using the specified capacity (int).

or

public StringBuilder(value)

Initializes a new instance of the StringBuilder class using the specified value (@String).

or

public StringBuilder(value, capacity)

Initializes a new instance of the StringBuilder class using the specified value (@String) and capacity (int).

Properties

Capacity

public Capacity

Gets or sets the maximum number of characters that can be contained in the memory allocated by the current instance, which can’t be less than the length. (int)

Length

public Length

Gets or sets the length of the current StringBuilder object. (int)

Methods

Append

public Append(alpha), @StringBuilder

Appends the string representation of the specified alpha value to the end of the current StringBuilder.

or

public Append(string), @StringBuilder

Appends the specified string to the end of the current StringBuilder.

AppendLine

public AppendLine(string), @StringBuilder

Appends the specified string and the default line terminator to the end of the current StringBuilder.

Clear

public Clear(), @StringBuilder

Removes all characters from the current StringBuilder, which sets the current length to 0.

EnsureCapacity

public EnsureCapacity(capacity), int

Ensures that the capacity of this instance of StringBuilder to at least capacity (int).

Equals

public Equals(sb), boolean

Compares the contents of sb (@StringBuilder) to the current instance and returns a value indicating whether the objects are equal.

Insert

public Insert(index, alpha), @StringBuilder

Inserts the string representation of the specified alpha value into the current StringBuilder instance at the specified index (int).

or

public Insert(index, string), @StringBuilder

Inserts string (@string) into the current StringBuilder instance at the specified index (int).

or

public Insert(index, alpha, count), @StringBuilder

Inserts the string representation of the specified alpha value into the current StringBuilder at the specified index (int) for count (int) number of times.

or

public Insert(index, string, count), @StringBuilder

Inserts string (@string) into the current StringBuilder instance at the specified index (int) for count (int) number of times.

Remove

public Remove(startindex, length), @StringBuilder

Removes length (int) characters beginning at startindex (int) from the current StringBuilder.

Replace

public Replace(old, new), @StringBuilder

Replaces all occurrences of old (@string) with new (@string).

or

public Replace(old, new, startindex, length), @StringBuilder

Replace all occurrences of old (@string) with new (@string) beginning at startindex (int) for the specified length (int) of text.

or

public Replace(old, new), @StringBuilder

Replaces all occurrences of old (alpha) with new (alpha).

or

public Replace(old, new, startindex, length), @StringBuilder

Replace all occurrences of old (alpha) with new (alpha) beginning at startindex (int) for the specified length (int).

ToString

public ToString(), @string

Returns a string with the current contents of StringBuilder.

or

public ToString(startindex, length), @string

Returns a string with the current contents of StringBuilder starting at startindex (int) for length (int).