Copy an array : Array Copy : Data Structure C# Examples


C# Examples » Data Structure » Array Copy »

 

Copy an array









    
using  System;    
    
class  MainClass  {          
    public  static  void  Main()  {          
        int[]  source  =  {  1,  2,  3,  4,  5  };  
        int[]  target  =  {  11,  12,  13,  14,  15  };  
        int[]  source2  =  {  -1,  -2,  -3,  -4,  -5  };  
  
        Array.Copy(source2,  2,  target,  3,  2);  
  
        Console.Write("target  after  copy:    ");  
        foreach(int  i  in  target)    
            Console.Write(i  +  "  ");  
        Console.WriteLine();  
  
    }  
}
    
   
  
   



Output

target after copy:  11 12 13 -3 -4


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Structure
» Array Copy