Multidimensional and Jagged Arrays:Jagged Arrays : Array Dimension « Collections Data Structure « C# / C Sharp






Multidimensional and Jagged Arrays:Jagged Arrays

Multidimensional and Jagged Arrays:Jagged Arrays
 
// 
using System;

public class JaggedArrays {
    
    public static void Main()
    {
        int[][] matrix = {new int[5], new int[4], new int[2] };
        matrix[0][3] = 4;
        matrix[1][1] = 8;
        matrix[2][0] = 5;
        
        for (int i = 0; i < matrix.Length; i++)
        {
            for (int j = 0; j < matrix[i].Length; j++)
            {
                Console.WriteLine("matrix[{0}, {1}] = {2}", i, j, matrix[i][j]);
            }
        }       
    }
}

           
         
  








Related examples in the same category

1.Demonstrate a two-dimensional arrayDemonstrate a two-dimensional array
2.Sum the values on a diagonal of a 3x3x3 matrixSum the values on a diagonal of a 3x3x3 matrix
3.Initialize a two-dimensional arrayInitialize a two-dimensional array
4.Demonstrate jagged arraysDemonstrate jagged arrays
5.Use the Length array property on a 3-D arrayUse the Length array property on a 3-D array
6.Call GetLength for two dimenional array
7.Demonstrate Length with jagged arraysDemonstrate Length with jagged arrays
8.illustrates the use of a two-dimensional rectangular arrayillustrates the use of a two-dimensional rectangular array
9.initialize a two-dimensional rectangular array, and use the array properties and methodsinitialize a two-dimensional rectangular array, and use the array properties and methods
10.the use of a three-dimensional rectangular arraythe use of a three-dimensional rectangular array
11.the use of a jagged arraythe use of a jagged array
12.Uses a two-dimensional array to store grades for studentsUses a two-dimensional array to store grades for students
13.Uses a jagged array to store sales figuresUses a jagged array to store sales figures
14.Multi dimensional Arrays 1Multi dimensional Arrays 1
15.Catch OutOfMemoryException
16.Catch IndexOutOfRangeException Exception
17.Defines a 2D Array