StringBuilderReplace Method (Char, Char, Int32, Int32) |
Replaces, within a substring of this instance, all occurrences of a specified character with another specified character.
Namespace: System.TextAssembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax public StringBuilder Replace(
char oldChar,
char newChar,
int startIndex,
int count
)
Parameters
- oldChar
- Type: SystemChar
The character to replace. - newChar
- Type: SystemChar
The character that replaces oldChar. - 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
oldChar replaced by
newChar in the range from
startIndex to
startIndex +
count -1.
Exceptions Exception | Condition |
---|
ArgumentOutOfRangeException | startIndex + count is greater than the length of the value of this instance.-or- startIndex or count is less than zero. |
See Also