কম্পিউটার

C# এ একটি অ্যারের একটি নির্দিষ্ট মাত্রায় উপাদানের মোট সংখ্যা


একটি অ্যারের একটি নির্দিষ্ট মাত্রায় উপাদানের মোট সংখ্যা পেতে, কোডটি নিম্নরূপ -

উদাহরণ

using System;
public class Demo {
   public static void Main() {
      string[] products = new string[] { "Andy", "Mark", "Gary", "Andre"};
      Console.WriteLine("One or more name begins 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));
      Console.WriteLine("GetLongLength(0) = "+products.GetLongLength(0));
   }
}

আউটপুট

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
One or more name begins 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
GetLongLength(0) = 4

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

উদাহরণ

using System;
public class Demo {
   public static void Main() {
      string[,, ] stdNames = new string[,, ] {
         { { "John", "Gary" },
            { "Jacob", "Harry" } },
         { { "Kevin", "Ryan" },
            { "David", "Mark" } },};
         Console.WriteLine("Is the array having fixed size? = " + stdNames.IsFixedSize);
         Console.WriteLine("Is the array read only? = " + stdNames.IsReadOnly);
         Console.WriteLine("Is the array synchronized? = " + stdNames.IsSynchronized);
         Console.WriteLine("Index of the 1st element = "+stdNames.GetLowerBound(0));
         Console.WriteLine("Index of the last element = "+stdNames.GetUpperBound(0));
         Console.WriteLine("GetLongLength(0) = "+stdNames.GetLongLength(0));
         Console.WriteLine("GetLongLength(0) = "+stdNames.GetLongLength(1));
   }
}

আউটপুট

এটি নিম্নলিখিত আউটপুট −

তৈরি করবে
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
GetLongLength(0) = 2
GetLongLength(0) = 2

  1. C# প্রোগ্রাম একটি অ্যারের শেষ থেকে নির্দিষ্ট সংখ্যক উপাদান ফেরত দেয়

  2. একটি অ্যারের প্রাথমিক উপাদানগুলি এড়িয়ে যাওয়ার জন্য C# প্রোগ্রাম

  3. একটি অ্যারেতে বাইটের সংখ্যা গণনা করার জন্য C# প্রোগ্রাম

  4. কিভাবে C# এ একটি অ্যারে থেকে উপাদান অ্যাক্সেস করবেন?