System.String.Replace Method

Returns a new string in which all occurrences of a specified string in the current instance are replaced with another specified string.

Syntax

public string Replace (string oldValue, string newValue)

Parameters

oldValue
The string to be replaced.
newValue
The string to replace all occurrences of oldValue.

Returns

A string that is equivalent to the current string except that all instances of oldValue are replaced with newValue. If oldValue is not found in the current instance, the method returns the current instance unchanged.

Remarks

If newValue is null, all occurrences of oldValue are removed.

Note:

This method does not modify the value of the current instance. Instead, it returns a new string in which all occurrences of oldValue are replaced by newValue.

This method performs an ordinal (case-sensitive and culture-insensitive) search to find oldValue.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0