System.String.Replace Method

Returns a new string in which all occurrences of a specified Unicode character in this instance are replaced with another specified Unicode character.

Syntax

public string Replace (char oldChar, char newChar)

Parameters

oldChar
The Unicode character to be replaced.
newChar
The Unicode character to replace all occurrences of oldChar.

Returns

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

Remarks

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

Note:

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

Requirements

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