C#-এ অ্যারের প্রথম এলিমেন্টের ইনডেক্স সবসময় ০। Array.GetLowerBound(dimension) মেথড দিয়ে যেকোনো ডাইমেনশনের নিচের বাউন্ড (সাধারণত ০) পাওয়া যায়।
উদাহরণ ১: স্ট্রিং অ্যারের প্রপার্টি ও GetLowerBound
using System;
public class Demo {
public static void Main() {
string[] products = new string[] { "Andy", "Mark", "Gary", "Andre" };
Console.WriteLine("One or more name begin with 'A'? = {0}", Array.Exists(products, ele => ele.StartsWith("A")));
Console.WriteLine("Is the array having fixed size? = " + products.IsFixedSize);
Console.WriteLine("Is the array read only? = " + products.IsReadOnly);
Console.WriteLine("Is the array synchronized? = " + products.IsSynchronized);
Console.WriteLine("Index of the 1st element = " + products.GetLowerBound(0));
}
}
আউটপুট
One or more name begin with 'A'? = True Is the array having fixed size? = True Is the array read only? = False Is the array synchronized? = False Index of the 1st element = 0
উদাহরণ ২: খালি অ্যারেও GetLowerBound
using System;
public class Demo {
public static void Main() {
string[] products = new string[] { };
Console.WriteLine("Is the array having fixed size? = " + products.IsFixedSize);
Console.WriteLine("Is the array read only? = " + products.IsReadOnly);
Console.WriteLine("Is the array synchronized? = " + products.IsSynchronized);
Console.WriteLine("Index of the 1st element = " + products.GetLowerBound(0));
}
}
আউটপুট
Is the array having fixed size? = True Is the array read only? = False Is the array synchronized? = False Index of the 1st element = 0
মূল পয়েন্টস
- C#-এ অ্যারে সবসময় ০-বেসড (first index = 0)।
GetLowerBound(0)প্রথম ডাইমেনশনের লোअার বাউন্ড রিটার্ন করে (সবসময় ০)।GetUpperBound(0)আপার বাউন্ড রিটার্ন করে (Length - 1)।- মাল্টি-ডাইমেনশনাল অ্যারেতে প্রতিটি ডাইমেনশনের জন্য আলাদা বাউন্ড থাকে।