A StringBuilder with all instances of a specified character in a specified range replaced with a new character.
[Visual Basic] Overloads Public Function Replace( _ ByVal oldChar As Char, _ ByVal newChar As Char, _ ByVal startIndex As Integer, _ ByVal count As Integer _ ) As StringBuilder [C#] public StringBuilder Replace( char oldChar, char newChar, int startIndex, int count ); [C++] public: StringBuilder* Replace( __wchar_t oldChar, __wchar_t newChar, int startIndex, int count ); [JScript] public function Replace( oldChar : Char, newChar : Char, startIndex : int, count : int ) : StringBuilder;
A StringBuilder with oldChar replaced with newChar in the specified range.
Exception Type | Condition |
---|---|
ArgumentOutOfRangeException | if startIndex and count do not specify a valid range. |
The size of the StringBuilder is unchanged because we're only replacing characters. We only replace characters in the range from startIndex to startIndex + count- 1. This method is case-sensitive.
StringBuilder Class | StringBuilder Members | System.Text Namespace | StringBuilder.Replace Overload List