Share via


Replace Method (String, String)

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

Replaces all occurrences of a specified string in this instance with another specified string.

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

Syntax

'Declaration
Public Function Replace ( _
    oldValue As String, _
    newValue As String _
) As StringBuilder
public StringBuilder Replace(
    string oldValue,
    string newValue
)
public:
StringBuilder^ Replace(
    String^ oldValue, 
    String^ newValue
)
member Replace : 
        oldValue:string * 
        newValue:string -> StringBuilder 
public function Replace(
    oldValue : String, 
    newValue : String
) : 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.

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