StringBuilderReplace Method (String, String, Int32, Int32) |
Replaces, within a substring of this instance, all occurrences of a specified string with another specified string.
Namespace: System.TextAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public StringBuilder Replace(
string oldValue,
string newValue,
int startIndex,
int count
)
Parameters
- oldValue
- Type: SystemString
The string to replace. - newValue
- Type: SystemString
The string that replaces oldValue, or null. - startIndex
- Type: SystemInt32
The position in this instance where the substring begins. - count
- Type: SystemInt32
The length of the substring.
Return Value
Type:
StringBuilderA reference to this instance with all instances of
oldValue replaced by
newValue in the range from
startIndex to
startIndex +
count - 1.
Exceptions Exception | Condition |
---|
ArgumentNullException | oldValue is null. |
ArgumentException | The length of oldValue is zero. |
ArgumentOutOfRangeException | startIndex or count is less than zero.-or- startIndex plus count indicates a character position not within this instance.-or- Enlarging the value of this instance would exceed MaxCapacity. |
See Also