System.Text.StringBuilder
Manipulate and modify a mutable string
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
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.
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).
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)
public Length
Gets or sets the length of the current StringBuilder object. (int)
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.
public AppendLine(string), @StringBuilder
Appends the specified string and the default line terminator to the end of the current StringBuilder.
public Clear(), @StringBuilder
Removes all characters from the current StringBuilder, which sets the current length to 0.
public EnsureCapacity(capacity), int
Ensures that the capacity of this instance of StringBuilder to at least capacity (int).
public Equals(sb), boolean
Compares the contents of sb (@StringBuilder) to the current instance and returns a value indicating whether the objects are equal.
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.
public Remove(startindex, length), @StringBuilder
Removes length (int) characters beginning at startindex (int) from the current StringBuilder.
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).
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).