How to replace a string in C# ?

By | April 17, 2011

Hi,
Want to know how to replace a string in C#? See the following code.

using System;

class MainClass {
  public static void Main() {
    string testStr= "Coderz";

    testStr= testStr.Replace("erz", "ings");
    Console.WriteLine(testStr);

  }
}

Guess output?
“Codings”

🙂

Leave a Reply

Your email address will not be published. Required fields are marked *