Demonstrate jagged arrays : Array Dimension : Collections Data Structure C# Source Code


Custom Search

C# Source Code » Collections Data Structure » Array Dimension »

 

Demonstrate jagged arrays









    

// Demonstrate jagged arrays. 
using System; 
 
public class Jagged1 {  
  public static void Main() {  
    int[][] jagged = new int[3][];  
    jagged[0] = new int[4];  
    jagged[1] = new int[3];  
    jagged[2] = new int[5];  
  
    int i; 
 
    // store values in first array 
    for(i=0; i < 4; i++)   
      jagged[0][i] = i;  
 
    // store values in second array 
    for(i=0; i < 3; i++)   
      jagged[1][i] = i;  
 
    // store values in third array 
    for(i=0; i < 5; i++)   
      jagged[2][i] = i;  
 
 
    // display values in first array 
    for(i=0; i < 4; i++)   
      Console.Write(jagged[0][i] + " ");  
 
    Console.WriteLine(); 
 
    // display values in second array 
    for(i=0; i < 3; i++)   
      Console.Write(jagged[1][i] + " ");  
 
    Console.WriteLine(); 
 
    // display values in third array 
    for(i=0; i < 5; i++)   
      Console.Write(jagged[2][i] + " ");  
 
    Console.WriteLine(); 
  }  
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Collections Data Structure
» Array Dimension