StringBuilder Class

Represents a mutable string of characters. This class cannot be inherited.

Syntax

Declaration

[ComVisible(true)]
[Serializable]
public sealed class StringBuilder : ISerializable

Inheritance Hierarchy

Inherited Members

System.Object

, , , , ,

Constructors summary

Initializes a new instance of the StringBuilder class.

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

Initializes a new instance of the StringBuilder class that starts with a specified capacity and can grow to a specified maximum.

Initializes a new instance of the StringBuilder class using the specified string.

Initializes a new instance of the StringBuilder class using the specified string and capacity.

Initializes a new instance of the StringBuilder class from the specified substring and capacity.

Properties summary

Gets or sets the maximum number of characters that can be contained in the memory allocated by the current instance.

Gets or sets the character at the specified character position in this instance.

Gets or sets the length of the current StringBuilder object.

Gets the maximum capacity of this instance.

Methods summary

Appends the string representation of a specified Boolean value to this instance.

Appends the string representation of a specified 8-bit unsigned integer to this instance.

Appends the string representation of a specified Char object to this instance.

Appends an array of Unicode characters starting at a specified address to this instance.

Appends a specified number of copies of the string representation of a Unicode character to this instance.

Appends the string representation of the Unicode characters in a specified array to this instance.

Appends the string representation of a specified subarray of Unicode characters to this instance.

Appends the string representation of a specified decimal number to this instance.

Appends the string representation of a specified double-precision floating-point number to this instance.

Appends the string representation of a specified 16-bit signed integer to this instance.

Appends the string representation of a specified 32-bit signed integer to this instance.

Appends the string representation of a specified 64-bit signed integer to this instance.

Appends the string representation of a specified object to this instance.

Appends the string representation of a specified 8-bit signed integer to this instance.

Appends the string representation of a specified single-precision floating-point number to this instance.

Appends a copy of the specified string to this instance.

Appends a copy of a specified substring to this instance.

Appends the string representation of a specified 16-bit unsigned integer to this instance.

Appends the string representation of a specified 32-bit unsigned integer to this instance.

Appends the string representation of a specified 64-bit unsigned integer to this instance.

Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a single argument using a specified format provider.

Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of two arguments using a specified format provider.

Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of three arguments using a specified format provider.

Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array using a specified format provider.

Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a single argument.

Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of two arguments.

Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of three arguments.

Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array.

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

Appends a copy of the specified string followed by the default line terminator to the end of the current StringBuilder object.

Removes all characters from the current StringBuilder instance.

Copies the characters from a specified segment of this instance to a specified segment of a destination Char array.

Ensures that the capacity of this instance of StringBuilder is at least the specified value.

Returns a value indicating whether this instance is equal to a specified object.

Inserts the string representation of a Boolean value into this instance at the specified character position.

Inserts the string representation of a specified 8-bit unsigned integer into this instance at the specified character position.

Inserts the string representation of a specified Unicode character into this instance at the specified character position.

Inserts the string representation of a specified array of Unicode characters into this instance at the specified character position.

Inserts the string representation of a specified subarray of Unicode characters into this instance at the specified character position.

Inserts the string representation of a decimal number into this instance at the specified character position.

Inserts the string representation of a double-precision floating-point number into this instance at the specified character position.

Inserts the string representation of a specified 16-bit signed integer into this instance at the specified character position.

Inserts the string representation of a specified 32-bit signed integer into this instance at the specified character position.

Inserts the string representation of a 64-bit signed integer into this instance at the specified character position.

Inserts the string representation of an object into this instance at the specified character position.

Inserts the string representation of a specified 8-bit signed integer into this instance at the specified character position.

Inserts the string representation of a single-precision floating point number into this instance at the specified character position.

Inserts a string into this instance at the specified character position.

Inserts one or more copies of a specified string into this instance at the specified character position.

Inserts the string representation of a 16-bit unsigned integer into this instance at the specified character position.

Inserts the string representation of a 32-bit unsigned integer into this instance at the specified character position.

Inserts the string representation of a 64-bit unsigned integer into this instance at the specified character position.

Removes the specified range of characters from this instance.

Replaces all occurrences of a specified character in this instance with another specified character.

Replaces, within a substring of this instance, all occurrences of a specified character with another specified character.

Replaces all occurrences of a specified string in this instance with another specified string.

Replaces, within a substring of this instance, all occurrences of a specified string with another specified string.

Converts the value of this instance to a String.

Converts the value of a substring of this instance to a String.

Constructors

  • StringBuilder()

    Initializes a new instance of the StringBuilder class.

    public StringBuilder()
  • StringBuilder(Int32)

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

    public StringBuilder(int capacity)

    Parameters

    • capacity

      The suggested starting size of this instance.

    Exceptions

  • StringBuilder(Int32, Int32)

    Initializes a new instance of the StringBuilder class that starts with a specified capacity and can grow to a specified maximum.

    public StringBuilder(int capacity, int maxCapacity)

    Parameters

    • capacity

      The suggested starting size of the StringBuilder.

    • maxCapacity

      The maximum number of characters the current string can contain.

    Exceptions

  • StringBuilder(String)

    Initializes a new instance of the StringBuilder class using the specified string.

    public StringBuilder(string value)

    Parameters

    • value

      The string used to initialize the value of the instance. If value is null, the new StringBuilder will contain the empty string (that is, it contains Empty).

  • StringBuilder(String, Int32)

    Initializes a new instance of the StringBuilder class using the specified string and capacity.

    public StringBuilder(string value, int capacity)

    Parameters

    • value

      The string used to initialize the value of the instance. If value is null, the new StringBuilder will contain the empty string (that is, it contains Empty).

    • capacity

      The suggested starting size of the StringBuilder.

    Exceptions

  • StringBuilder(String, Int32, Int32, Int32)

    Initializes a new instance of the StringBuilder class from the specified substring and capacity.

    public StringBuilder(string value, int startIndex, int length, int capacity)

    Parameters

    • value

      The string that contains the substring used to initialize the value of this instance. If value is null, the new StringBuilder will contain the empty string (that is, it contains Empty).

    • startIndex

      The position within value where the substring begins.

    • length

      The number of characters in the substring.

    • capacity

      The suggested starting size of the StringBuilder.

    Exceptions

Properties

  • Capacity

    Gets or sets the maximum number of characters that can be contained in the memory allocated by the current instance.

    public int Capacity { get; set; }

    Property Value

    • The maximum number of characters that can be contained in the memory allocated by the current instance. Its value can range from Length to MaxCapacity.

    Exceptions

    • The value specified for a set operation is less than the current length of this instance.

      -or-

      The value specified for a set operation is greater than the maximum capacity.

  • Chars[Int32]

    Gets or sets the character at the specified character position in this instance.

    public char this[int index] { get; set; }

    Parameters

    • index

      The position of the character.

    Property Value

    • The Unicode character at position index.

    Exceptions

  • Length

    Gets or sets the length of the current StringBuilder object.

    public int Length { get; set; }

    Property Value

    • The length of this instance.

    Exceptions

  • MaxCapacity

    Gets the maximum capacity of this instance.

    public int MaxCapacity { get; }

    Property Value

    • The maximum number of characters this instance can hold.

Methods

  • Append(Boolean)

    Appends the string representation of a specified Boolean value to this instance.

    public StringBuilder Append(bool value)

    Parameters

    • value

      The Boolean value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Byte)

    Appends the string representation of a specified 8-bit unsigned integer to this instance.

    public StringBuilder Append(byte value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Char)

    Appends the string representation of a specified Char object to this instance.

    public StringBuilder Append(char value)

    Parameters

    • value

      The UTF-16-encoded code unit to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Char*, Int32)

    Appends an array of Unicode characters starting at a specified address to this instance.

    [SecurityCritical]
    [CLSCompliant(false)]
    public StringBuilder Append(char *value, int valueCount)

    Parameters

    • value

      A pointer to an array of characters.

    • valueCount

      The number of characters in the array.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Char, Int32)

    Appends a specified number of copies of the string representation of a Unicode character to this instance.

    public StringBuilder Append(char value, int repeatCount)

    Parameters

    • value

      The character to append.

    • repeatCount

      The number of times to append value.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Char[])

    Appends the string representation of the Unicode characters in a specified array to this instance.

    public StringBuilder Append(char[] value)

    Parameters

    • value

      The array of characters to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Char[], Int32, Int32)

    Appends the string representation of a specified subarray of Unicode characters to this instance.

    public StringBuilder Append(char[] value, int startIndex, int charCount)

    Parameters

    • value

      A character array.

    • startIndex

      The starting position in value.

    • charCount

      The number of characters to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

    • value is null, and startIndex and charCount are not zero.

    • charCount is less than zero.

      -or-

      startIndex is less than zero.

      -or-

      startIndex + charCount is greater than the length of value.

      -or-

      Enlarging the value of this instance would exceed MaxCapacity.

  • Append(Decimal)

    Appends the string representation of a specified decimal number to this instance.

    public StringBuilder Append(decimal value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Double)

    Appends the string representation of a specified double-precision floating-point number to this instance.

    public StringBuilder Append(double value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Int16)

    Appends the string representation of a specified 16-bit signed integer to this instance.

    public StringBuilder Append(short value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Int32)

    Appends the string representation of a specified 32-bit signed integer to this instance.

    public StringBuilder Append(int value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Int64)

    Appends the string representation of a specified 64-bit signed integer to this instance.

    public StringBuilder Append(long value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Object)

    Appends the string representation of a specified object to this instance.

    public StringBuilder Append(object value)

    Parameters

    • value

      The object to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(SByte)

    Appends the string representation of a specified 8-bit signed integer to this instance.

    [CLSCompliant(false)]
    public StringBuilder Append(sbyte value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(Single)

    Appends the string representation of a specified single-precision floating-point number to this instance.

    public StringBuilder Append(float value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(String)

    Appends a copy of the specified string to this instance.

    public StringBuilder Append(string value)

    Parameters

    • value

      The string to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(String, Int32, Int32)

    Appends a copy of a specified substring to this instance.

    public StringBuilder Append(string value, int startIndex, int count)

    Parameters

    • value

      The string that contains the substring to append.

    • startIndex

      The starting position of the substring within value.

    • count

      The number of characters in value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(UInt16)

    Appends the string representation of a specified 16-bit unsigned integer to this instance.

    [CLSCompliant(false)]
    public StringBuilder Append(ushort value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(UInt32)

    Appends the string representation of a specified 32-bit unsigned integer to this instance.

    [CLSCompliant(false)]
    public StringBuilder Append(uint value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Append(UInt64)

    Appends the string representation of a specified 64-bit unsigned integer to this instance.

    [CLSCompliant(false)]
    public StringBuilder Append(ulong value)

    Parameters

    • value

      The value to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • AppendFormat(IFormatProvider, String, Object)

    Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a single argument using a specified format provider.

    public StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0)

    Parameters

    • provider

      An object that supplies culture-specific formatting information.

    • format

      A composite format string (see Remarks).

    • arg0

      The object to format.

    Returns

    • A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of format in which any format specification is replaced by the string representation of arg0.

    Exceptions

  • AppendFormat(IFormatProvider, String, Object, Object)

    Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of two arguments using a specified format provider.

    public StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0, object arg1)

    Parameters

    • provider

      An object that supplies culture-specific formatting information.

    • format

      A composite format string (see Remarks).

    • arg0

      The first object to format.

    • arg1

      The second object to format.

    Returns

    • A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of format where any format specification is replaced by the string representation of the corresponding object argument.

    Exceptions

  • AppendFormat(IFormatProvider, String, Object, Object, Object)

    Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of three arguments using a specified format provider.

    public StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0, object arg1, object arg2)

    Parameters

    • provider

      An object that supplies culture-specific formatting information.

    • format

      A composite format string (see Remarks).

    • arg0

      The first object to format.

    • arg1

      The second object to format.

    • arg2

      The third object to format.

    Returns

    • A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of format where any format specification is replaced by the string representation of the corresponding object argument.

    Exceptions

  • AppendFormat(IFormatProvider, String, Object[])

    Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array using a specified format provider.

    public StringBuilder AppendFormat(IFormatProvider provider, string format, params object[] args)

    Parameters

    • provider

      An object that supplies culture-specific formatting information.

    • format

      A composite format string (see Remarks).

    • args

      An array of objects to format.

    Returns

    • A reference to this instance after the append operation has completed. After the append operation, this instance contains any data that existed before the operation, suffixed by a copy of format where any format specification is replaced by the string representation of the corresponding object argument.

    Exceptions

  • AppendFormat(String, Object)

    Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a single argument.

    public StringBuilder AppendFormat(string format, object arg0)

    Parameters

    • format

      A composite format string (see Remarks).

    • arg0

      An object to format.

    Returns

    • A reference to this instance with format appended. Each format item in format is replaced by the string representation of arg0.

    Exceptions

  • AppendFormat(String, Object, Object)

    Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of two arguments.

    public StringBuilder AppendFormat(string format, object arg0, object arg1)

    Parameters

    • format

      A composite format string (see Remarks).

    • arg0

      The first object to format.

    • arg1

      The second object to format.

    Returns

    • A reference to this instance with format appended. Each format item in format is replaced by the string representation of the corresponding object argument.

    Exceptions

  • AppendFormat(String, Object, Object, Object)

    Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of either of three arguments.

    public StringBuilder AppendFormat(string format, object arg0, object arg1, object arg2)

    Parameters

    • format

      A composite format string (see Remarks).

    • arg0

      The first object to format.

    • arg1

      The second object to format.

    • arg2

      The third object to format.

    Returns

    • A reference to this instance with format appended. Each format item in format is replaced by the string representation of the corresponding object argument.

    Exceptions

  • AppendFormat(String, Object[])

    Appends the string returned by processing a composite format string, which contains zero or more format items, to this instance. Each format item is replaced by the string representation of a corresponding argument in a parameter array.

    public StringBuilder AppendFormat(string format, params object[] args)

    Parameters

    • format

      A composite format string (see Remarks).

    • args

      An array of objects to format.

    Returns

    • A reference to this instance with format appended. Each format item in format is replaced by the string representation of the corresponding object argument.

    Exceptions

  • AppendLine()

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

    [ComVisible(false)]
    public StringBuilder AppendLine()

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • AppendLine(String)

    Appends a copy of the specified string followed by the default line terminator to the end of the current StringBuilder object.

    [ComVisible(false)]
    public StringBuilder AppendLine(string value)

    Parameters

    • value

      The string to append.

    Returns

    • A reference to this instance after the append operation has completed.

    Exceptions

  • Clear()

    Removes all characters from the current StringBuilder instance.

    public StringBuilder Clear()

    Returns

  • CopyTo(Int32, Char[], Int32, Int32)

    Copies the characters from a specified segment of this instance to a specified segment of a destination Char array.

    [ComVisible(false)]
    public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)

    Parameters

    • sourceIndex

      The starting position in this instance where characters will be copied from. The index is zero-based.

    • destination

      The array where characters will be copied.

    • destinationIndex

      The starting position in destination where characters will be copied. The index is zero-based.

    • count

      The number of characters to be copied.

    Exceptions

    • destination is null.

    • sourceIndex, destinationIndex, or count, is less than zero.

      -or-

      sourceIndex is greater than the length of this instance.

    • sourceIndex + count is greater than the length of this instance.

      -or-

      destinationIndex + count is greater than the length of destination.

  • EnsureCapacity(Int32)

    Ensures that the capacity of this instance of StringBuilder is at least the specified value.

    public int EnsureCapacity(int capacity)

    Parameters

    • capacity

      The minimum capacity to ensure.

    Returns

    • The new capacity of this instance.

    Exceptions

  • Equals(StringBuilder)

    Returns a value indicating whether this instance is equal to a specified object.

    public bool Equals(StringBuilder sb)

    Parameters

    • sb

      An object to compare with this instance, or null.

    Returns

  • Insert(Int32, Boolean)

    Inserts the string representation of a Boolean value into this instance at the specified character position.

    public StringBuilder Insert(int index, bool value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Byte)

    Inserts the string representation of a specified 8-bit unsigned integer into this instance at the specified character position.

    public StringBuilder Insert(int index, byte value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Char)

    Inserts the string representation of a specified Unicode character into this instance at the specified character position.

    public StringBuilder Insert(int index, char value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Char[])

    Inserts the string representation of a specified array of Unicode characters into this instance at the specified character position.

    public StringBuilder Insert(int index, char[] value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The character array to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Char[], Int32, Int32)

    Inserts the string representation of a specified subarray of Unicode characters into this instance at the specified character position.

    public StringBuilder Insert(int index, char[] value, int startIndex, int charCount)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      A character array.

    • startIndex

      The starting index within value.

    • charCount

      The number of characters to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

    • value is null, and startIndex and charCount are not zero.

    • index, startIndex, or charCount is less than zero.

      -or-

      index is greater than the length of this instance.

      -or-

      startIndex plus charCount is not a position within value.

      -or-

      Enlarging the value of this instance would exceed MaxCapacity.

  • Insert(Int32, Decimal)

    Inserts the string representation of a decimal number into this instance at the specified character position.

    public StringBuilder Insert(int index, decimal value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Double)

    Inserts the string representation of a double-precision floating-point number into this instance at the specified character position.

    public StringBuilder Insert(int index, double value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Int16)

    Inserts the string representation of a specified 16-bit signed integer into this instance at the specified character position.

    public StringBuilder Insert(int index, short value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Int32)

    Inserts the string representation of a specified 32-bit signed integer into this instance at the specified character position.

    public StringBuilder Insert(int index, int value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Int64)

    Inserts the string representation of a 64-bit signed integer into this instance at the specified character position.

    public StringBuilder Insert(int index, long value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Object)

    Inserts the string representation of an object into this instance at the specified character position.

    public StringBuilder Insert(int index, object value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The object to insert, or null.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, SByte)

    Inserts the string representation of a specified 8-bit signed integer into this instance at the specified character position.

    [CLSCompliant(false)]
    public StringBuilder Insert(int index, sbyte value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, Single)

    Inserts the string representation of a single-precision floating point number into this instance at the specified character position.

    public StringBuilder Insert(int index, float value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, String)

    Inserts a string into this instance at the specified character position.

    public StringBuilder Insert(int index, string value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The string to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, String, Int32)

    Inserts one or more copies of a specified string into this instance at the specified character position.

    public StringBuilder Insert(int index, string value, int count)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The string to insert.

    • count

      The number of times to insert value.

    Returns

    • A reference to this instance after insertion has completed.

    Exceptions

  • Insert(Int32, UInt16)

    Inserts the string representation of a 16-bit unsigned integer into this instance at the specified character position.

    [CLSCompliant(false)]
    public StringBuilder Insert(int index, ushort value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, UInt32)

    Inserts the string representation of a 32-bit unsigned integer into this instance at the specified character position.

    [CLSCompliant(false)]
    public StringBuilder Insert(int index, uint value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Insert(Int32, UInt64)

    Inserts the string representation of a 64-bit unsigned integer into this instance at the specified character position.

    [CLSCompliant(false)]
    public StringBuilder Insert(int index, ulong value)

    Parameters

    • index

      The position in this instance where insertion begins.

    • value

      The value to insert.

    Returns

    • A reference to this instance after the insert operation has completed.

    Exceptions

  • Remove(Int32, Int32)

    Removes the specified range of characters from this instance.

    public StringBuilder Remove(int startIndex, int length)

    Parameters

    • startIndex

      The zero-based position in this instance where removal begins.

    • length

      The number of characters to remove.

    Returns

    • A reference to this instance after the excise operation has completed.

    Exceptions

    • If startIndex or length is less than zero, or startIndex + length is greater than the length of this instance.

  • Replace(Char, Char)

    Replaces all occurrences of a specified character in this instance with another specified character.

    public StringBuilder Replace(char oldChar, char newChar)

    Parameters

    • oldChar

      The character to replace.

    • newChar

      The character that replaces oldChar.

    Returns

    • A reference to this instance with oldChar replaced by newChar.

  • Replace(Char, Char, Int32, Int32)

    Replaces, within a substring of this instance, all occurrences of a specified character with another specified character.

    public StringBuilder Replace(char oldChar, char newChar, int startIndex, int count)

    Parameters

    • oldChar

      The character to replace.

    • newChar

      The character that replaces oldChar.

    • startIndex

      The position in this instance where the substring begins.

    • count

      The length of the substring.

    Returns

    • A reference to this instance with oldChar replaced by newChar in the range from startIndex to startIndex + count -1.

    Exceptions

    • startIndex + count is greater than the length of the value of this instance.

      -or-

      startIndex or count is less than zero.

  • Replace(String, String)

    Replaces all occurrences of a specified string in this instance with another specified string.

    public StringBuilder Replace(string oldValue, string newValue)

    Parameters

    • oldValue

      The string to replace.

    • newValue

      The string that replaces oldValue, or null.

    Returns

    • A reference to this instance with all instances of oldValue replaced by newValue.

    Exceptions

  • Replace(String, String, Int32, Int32)

    Replaces, within a substring of this instance, all occurrences of a specified string with another specified string.

    public StringBuilder Replace(string oldValue, string newValue, int startIndex, int count)

    Parameters

    • oldValue

      The string to replace.

    • newValue

      The string that replaces oldValue, or null.

    • startIndex

      The position in this instance where the substring begins.

    • count

      The length of the substring.

    Returns

    • A reference to this instance with all instances of oldValue replaced by newValue in the range from startIndex to startIndex + count - 1.

    Exceptions

  • ToString()

    Converts the value of this instance to a String.

    public override string ToString()

    Returns

    • A string whose value is the same as this instance.

    Overrides

  • ToString(Int32, Int32)

    Converts the value of a substring of this instance to a String.

    public string ToString(int startIndex, int length)

    Parameters

    • startIndex

      The starting position of the substring in this instance.

    • length

      The length of the substring.

    Returns

    • A string whose value is the same as the specified substring of this instance.

    Exceptions

    • startIndex or length is less than zero.

      -or-

      The sum of startIndex and length is greater than the length of the current instance.

Details

Namespace

System.Text

Assembly

System.Runtime.dll

See Also