কম্পিউটার

C# এ অ্যারের শেষ উপাদানের সূচী খোঁজা


অ্যারের শেষ উপাদানটির সূচক খুঁজে পেতে, কোডটি নিম্নরূপ -

উদাহরণ

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));
      Console.WriteLine("Index of the last element = "+products.GetUpperBound(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
Index of the last element = 3

উদাহরণ

এখন আরেকটি উদাহরণ দেখা যাক -

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));
      Console.WriteLine("Index of the last element = "+products.GetUpperBound(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
Index of the last element = -1

  1. C# ব্যবহার করে একটি অ্যারে থেকে শেষ উপাদান পেতে প্রোগ্রাম

  2. একটি অ্যারের মধ্যে শেষ ম্যাচিং উপাদান খুঁজে পেতে C# প্রোগ্রাম

  3. একটি অ্যারে থেকে শেষ উপাদান পেতে C# প্রোগ্রাম

  4. কিভাবে পাইথনে একটি তালিকার শেষ উপাদান পেতে?