Share via


Replace Method (String, String, Int32, Int32)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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

Namespace:  System.Text
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Function Replace ( _
    oldValue As String, _
    newValue As String, _
    startIndex As Integer, _
    count As Integer _
) As StringBuilder
public StringBuilder Replace(
    string oldValue,
    string newValue,
    int startIndex,
    int count
)
public:
StringBuilder^ Replace(
    String^ oldValue, 
    String^ newValue, 
    int startIndex, 
    int count
)
member Replace : 
        oldValue:string * 
        newValue:string * 
        startIndex:int * 
        count:int -> StringBuilder 
public function Replace(
    oldValue : String, 
    newValue : String, 
    startIndex : int, 
    count : int
) : StringBuilder

Parameters

  • newValue
    Type: System. . :: . .String
    The string that replaces oldValue, or nullNothingnullptrunita null reference (Nothing in Visual Basic).

Return Value

Type: System.Text. . :: . .StringBuilder
A reference to this instance with all instances of oldValue replaced by newValue in the range from startIndex to startIndex + count - 1.

Remarks

The strings to replace are checked on an ordinal basis; that is, the replacement is not culture-aware. If newValue is null Nothing nullptr unit a null reference (Nothing in Visual Basic) or String..::..Empty, all occurrences of oldValue are removed. This method is case-sensitive.

.NET Framework Security

See Also

Reference

StringBuilder Class

Replace Overload

System.Text Namespace