Change element in a string array : String Array : String C# Examples


C# Examples » String » String Array »

 

Change element in a string array









    
using  System;  
  
class  MainClass  {    
    public  static  void  Main()  {    
        string[]  str  =  {  "This",  "is",  "a",  "test."  };    
    
        Console.WriteLine("Original  array:  ");    
        for(int  i=0;  i  <  str.Length;  i++)  
            Console.Write(str[i]  +  "  ");    
        Console.WriteLine("\n");    
    
        //  change  a  string    
        str[1]  =  "was";    
        str[3]  =  "test,  too!";    
    
        Console.WriteLine("Modified  array:  ");  
        for(int  i=0;  i  <  str.Length;  i++)  
            Console.Write(str[i]  +  "  ");    
    }    
}
    
   
  
   



Output

Original array:
This is a test.

Modified array:
This was a test, too!


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo String
» String Array