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


Custom Search

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

 

Demonstrate Length with jagged arrays









    

// Demonstrate Length with jagged arrays. 
 
using System; 
 
public class Jagged {  
  public static void Main() {  
    int[][] network_nodes = new int[4][];  
    network_nodes[0] = new int[3];  
    network_nodes[1] = new int[7];  
    network_nodes[2] = new int[2];  
    network_nodes[3] = new int[5];  
 
  
    int i, j; 
 
    // fabricate some fake CPU usage data    
    for(i=0; i < network_nodes.Length; i++)   
      for(j=0; j < network_nodes[i].Length; j++)  
        network_nodes[i][j] = i * j + 70;  
 
 
    Console.WriteLine("Total number of network nodes: " + network_nodes.Length + "\n"); 
 
    for(i=0; i < network_nodes.Length; i++) {  
      for(j=0; j < network_nodes[i].Length; j++) { 
        Console.Write("CPU usage at node " + i +  
                      " CPU " + j + ": "); 
        Console.Write(network_nodes[i][j] + "% ");  
        Console.WriteLine();  
      } 
      Console.WriteLine();  
    } 
 
  }  
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Collections Data Structure
» Array Dimension