Click or drag to resize
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.Text
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
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: StringBuilder
A reference to this instance with oldChar replaced by newChar in the range from startIndex to startIndex + count -1.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionstartIndex + count is greater than the length of the value of this instance.-or- startIndex or count is less than zero.
See Also