C# Program to Find the Length of Jagged Array using Predefined Functions

This is a C# Program to find the length of the jagged array using predefined functions.

Problem Description

This C# Program Finds the Length of the Jagged Array using Predefined Functions.

Problem Solution

Here the Length of each row in the jagged array is calculated and displayed.

Program/Source Code

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();
    }
}
Program Explanation

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.

advertisement

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.

Runtime Test Cases
 
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.

⚡ Hurry! Secure Your Free Cyber Security Certification - December 2025
If you wish to look at all C# Programming examples, go to 1000 C# Programs.

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
I’m Manish - Founder and CTO at Sanfoundry. I’ve been working in tech for over 25 years, with deep focus on Linux kernel, SAN technologies, Advanced C, Full Stack and Scalable website designs.

You can connect with me on LinkedIn, watch my Youtube Masterclasses, or join my Telegram tech discussions.

If you’re in your 20s–40s and exploring new directions in your career, I also offer mentoring. Learn more here.