- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find the length and rank of a jagged array in C#?
Firstly, set a jagged array.
int[][] arr = new int[][] { new int[] { 0, 0 }, new int[] { 1, 2 }, new int[] { 2, 4 }, new int[] { 3, 6 }, new int[] { 4, 8 } };
Now, use the GetLowerBound(), GetUpperBound() and Rank property to get the lenth and rank of the array as shown in the following code −
Example
using System; public class Program { public static void Main() { int[][] arr = new int[][] { new int[] { 0, 0 }, new int[] { 1, 2 }, new int[] { 2, 4 }, new int[] { 3, 6 }, new int[] { 4, 8 } }; // Length Console.WriteLine("Length:" + arr.Length); Console.WriteLine("Upper Bound: {0}", arr.GetUpperBound(0).ToString()); Console.WriteLine("Lower Bound: {0}", arr.GetLowerBound(0).ToString()); Console.WriteLine("Dimensions of Array : " + arr.Rank); } }
Output
Length:5 Upper Bound: 4 Lower Bound: 0 Dimensions of Array : 1
- Related Articles
- How to find the length of jagged array using a property?
- How to find the Rank of a given Array in C#?
- How to define the rank of an array in C#?
- Jagged Array in C#
- How to access elements from jagged array in C#?
- How to use use an array of pointers (Jagged) in C/C++?
- How to find the rank of a matrix in R?
- Get rank of a three-dimensional array in C#
- How to add items/elements to an existing jagged array in C#?
- What is the type of elements of the jagged array in C#?
- Jagged Array in Java
- How do I find the length of an array in C/C++?
- How do you find the length of an array in C#?
- What are the differences between a multi-dimensional array and jagged array?
- How to initialize jagged arrays in C#?

Advertisements