Length of row 0 is 3 Length of row 1 is 4 Length of row 2 is 5 Length of row 3 is 6 Length of row 4 is 7
This is a C# Program to find the length of the jagged array using predefined functions.
This C# Program Finds the Length of the Jagged Array using Predefined Functions.
Here the Length of each row in the jagged array is calculated and displayed.
Here is source code of the C# Program to Find the Length of the Jagged Array using Predefined Functions. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Find the Length of the Jagged Array using Predefined Functions */ using System; class Program { public static void Main() { byte[][] numbers = new byte[5][]; for (int i = 0; i < numbers.Length; i++) { numbers[i] = new byte[i + 3]; } for (int i = 0; i < numbers.Length; i++) { Console.WriteLine("Length of row {0} is {1}", i, numbers[i].Length); } Console.Read(); } }
This C# program is used to find the length of the jagged array using predefined functions. A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes.
A jagged array is sometimes called an “array of arrays.” The following examples show how to declare, initialize, and access jagged arrays. For loop is used to assign an element value starting with 3 for an array. Hence another for loop is used to print the elements of an array.
Length of row 0 is 3 Length of row 1 is 4 Length of row 2 is 5 Length of row 3 is 6 Length of row 4 is 7