Replace method replaces all occurrences of a particular character or substring:
using System; class MainClass/*w w w . j a va2s .c o m*/ { public static void Main(string[] args) { Console.WriteLine ("this is a test".Replace (" ", " | ") ); Console.WriteLine ("this is a test".Replace (" ", "") ); } }