CSharp examples for Language Basics:StringBuilder
Demonstrating method Replace.
using System;//from w w w.j a va 2 s .c o m using System.Text; class StringBuilderReplace { static void Main() { var builder1 = new StringBuilder("Happy Birthday Jane"); var builder2 = new StringBuilder("goodbye greg"); Console.WriteLine($"Before replacements:\n{builder1}\n{builder2}"); builder1.Replace("Jane", "Greg"); builder2.Replace('g', 'G', 0, 5); Console.WriteLine($"\nAfter replacements:\n{builder1}\n{builder2}"); } }