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();
}
}
Here is the output of the C# Program:
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
Sanfoundry Global Education & Learning Series – 1000 C# Programs.
If you wish to look at all C# Programming examples, go to 1000 C# Programs.