Welcome to W3Courses
 Like Us on Facebook

String Replace Function in C#

The following code will replace a character or a word with some other character or a word. This is accomplished by the replace function in C#.

using System;
using System.Text.RegularExpressions;

string strReplace;
strReplace = "This is a test string.";
strReplace = Regex.Replace(strReplace, " is", " was");

Share