Replaces all occurrences of a specified character in this instance with another specified character.
using System;
using System.Text;
class Sample
{
public static void Main()
{
string str = "";
StringBuilder sb = new StringBuilder(str);
Console.WriteLine("Original value:");
Console.WriteLine(sb);
sb.Replace('#', '!', 15, 29);
Console.WriteLine(sb);
sb.Replace('!', 'o');
Console.WriteLine(sb);
sb.Replace("cat", "dog");
Console.WriteLine(sb);
sb.Replace("dog", "fox", 1, 20);
Console.WriteLine(sb);
}
}
Related examples in the same category