Inserting, replacing, and removing : String Replace : Data Types C# Source Code


Custom Search

C# Source Code » Data Types » String Replace »

 

Inserting, replacing, and removing









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/


// Inserting, replacing, and removing. 
  
using System;  
  
public class InsRepRevDemo {  
  public static void Main() {  
    string str = "This test"; 
 
    Console.WriteLine("Original string: " + str); 
     
    // Insert 
    str = str.Insert(5, "is a "); 
    Console.WriteLine(str); 
 
    // Replace string 
    str = str.Replace("is", "was"); 
    Console.WriteLine(str); 
 
    // Replace characters 
    str = str.Replace('a', 'X'); 
    Console.WriteLine(str); 
 
    // Remove 
    str = str.Remove(4, 5); 
    Console.WriteLine(str); 
  } 
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Data Types
» String Replace