use the Insert(), Remove(), and Replace() methods to modify strings : String Replace : Data Types C# Source Code


Custom Search

C# Source Code » Data Types » String Replace »

 

use the Insert(), Remove(), and Replace() methods to modify strings








    
 

using System;

class MainClass {

    public static void Main() {

        string[] myStrings = {"To", "be", "or", "not","to", "be"};
        string myString = String.Join(".", myStrings);    
                
        string myString10 = myString.Insert(6, "friends, ");
        Console.WriteLine("myString.Insert(6,\"friends, \") = " + myString10);
        string myString11 = myString10.Remove(14, 7);
        Console.WriteLine("myString10.Remove(14, 7) = " + myString11);
        string myString12 = myString11.Replace(',', '?');
        Console.WriteLine("myString11.Replace(',', '?') = " + myString12);
        string myString13 =myString12.Replace("to be", "Or not to be friends");
        Console.WriteLine("myString12.Replace(\"to be\",\"Or not to be friends\") = " + myString13);
    
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Data Types
» String Replace