string class : Replace(string,string) method

Description

Gets a new instance of the string in which all occurrences of a specified string in the invoker string are replaced with specified string.

Syntax

stringInstance.Replace(string oldString, string newString)

Arguments

ClassNameDescription
stringoldStringString to be replaced.
stringnewStringString to replace.

Return value

ClassDescription
stringA new instance of the string in which all occurrences of a specified string in the invoker string are replaced with specified string.

Sample code

//anyString is a instance of string type.

string replacedString = anyString.Replace("ww", "xx");

Notes

It's a wrapper of the System.String.Replace(String,String).

Links for reference

Copyright © Rice All rights reserved.