उदाहरण 1: सरणी के पहले और अंतिम तत्व का इंडेक्स प्राप्त करना
using System;
public class Demo {
public static void Main() {
string[] products = new string[] { "Andy", "Mark", "Gary", "Andre" };
Console.WriteLine("क्या एक या अधिक नाम 'A' से शुरू होते हैं? = {0}",
Array.Exists(products, ele => ele.StartsWith("A")));
Console.WriteLine("क्या सरणी का आकार निश्चित है? = " + products.IsFixedSize);
Console.WriteLine("क्या सरणी केवल पढ़ने योग्य है? = " + products.IsReadOnly);
Console.WriteLine("क्या सरणी सिंक्रनाइज़्ड है? = " + products.IsSynchronized);
Console.WriteLine("पहले तत्व का इंडेक्स = " + products.GetLowerBound(0));
Console.WriteLine("अंतिम तत्व का इंडेक्स = " + products.GetUpperBound(0));
}
}
आउटपुट
क्या एक या अधिक नाम 'A' से शुरू होते हैं? = True
क्या सरणी का आकार निश्चित है? = True
क्या सरणी केवल पढ़ने योग्य है? = False
क्या सरणी सिंक्रनाइज़्ड है? = False
पहले तत्व का इंडेक्स = 0
अंतिम तत्व का इंडेक्स = 3
उदाहरण 2: खाली सरणी के इंडेक्स प्राप्त करना
using System;
public class Demo {
public static void Main() {
string[] products = new string[] { };
Console.WriteLine("क्या सरणी का आकार निश्चित है? = " + products.IsFixedSize);
Console.WriteLine("क्या सरणी केवल पढ़ने योग्य है? = " + products.IsReadOnly);
Console.WriteLine("क्या सरणी सिंक्रनाइज़्ड है? = " + products.IsSynchronized);
Console.WriteLine("पहले तत्व का इंडेक्स = " + products.GetLowerBound(0));
Console.WriteLine("अंतिम तत्व का इंडेक्स = " + products.GetUpperBound(0));
}
}
आउटपुट
क्या सरणी का आकार निश्चित है? = True
क्या सरणी केवल पढ़ने योग्य है? = False
क्या सरणी सिंक्रनाइज़्ड है? = False
पहले तत्व का इंडेक्स = 0
अंतिम तत्व का इंडेक्स = -1