सबसे पहले, एक जैग्ड सरणी सेट करें।
int[][] arr = new int[][] {
new int[] { 0, 0 },
new int[] { 1, 2 },
new int[] { 2, 4 },
new int[] { 3, 6 },
new int[] { 4, 8 }
};
अब, सरणी की लंबाई और रैंक प्राप्त करने के लिए GetLowerBound(), GetUpperBound() और Rank प्रॉपर्टी का उपयोग करें जैसा कि निम्नलिखित कोड में दिखाया गया है:
उदाहरण
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 }
};
// लंबाई
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);
}
}
आउटपुट
Length:5 Upper Bound: 4 Lower Bound: 0 Dimensions of Array : 1