কম্পিউটার

C# এ তালিকায় একটি উপাদান যোগ করা হচ্ছে


তালিকায় একটি উপাদান যোগ করতে, কোডটি নিম্নরূপ -

উদাহরণ

using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(String[] args) {
      List<String> list = new List<String>();
      list.Add("One");
      list.Add("Two");
      list.Add("Three");
      list.Add("Four");
      list.Add("Five");
      list.Add("Six");
      list.Add("Seven");
      list.Add("Eight");
      Console.WriteLine("Enumerator iterates through the list elements...");
      List<string>.Enumerator demoEnum = list.GetEnumerator();
      while (demoEnum.MoveNext()) {
         string res = demoEnum.Current;
         Console.WriteLine(res);
      }
   }
}

আউটপুট

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

তৈরি করবে
Enumerator iterates through the list elements...
One
Two
Three
Four
Five
Six
Seven
Eight

উদাহরণ

আসুন আরেকটি উদাহরণ দেখি -

using System;
using System.Collections.Generic;
public class Demo {
   public static void Main(String[] args) {
      List<int> list = new List<int>();
      list.Add(50);
      list.Add(100);
      list.Add(150);
      list.Add(200);
      list.Add(250);
      list.Add(500);
      list.Add(750);
      list.Add(1000);
      list.Add(1250);
      list.Add(1500);
      Console.WriteLine("Enumerator iterates through the list elements...");
      List<int>.Enumerator demoEnum = list.GetEnumerator();
      while (demoEnum.MoveNext()) {
         int res = demoEnum.Current;
         Console.WriteLine(res);
      }
   }
}

আউটপুট

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

তৈরি করবে
Enumerator iterates through the list elements...
50
100
150
200
250
500
750
1000
1250
1500

  1. কিভাবে HTML এ উপাদানের উচ্চতা যোগ করবেন?

  2. কিভাবে HTML এ উপাদানের মান যোগ করবেন?

  3. পূর্ণসংখ্যার একটি পাইথন তালিকার প্রতিটি উপাদানে K যোগ করা হচ্ছে

  4. সূচীকরণের সাহায্যে একটি পাইথন তালিকায় উপাদান যোগ করুন