কম্পিউটার টিউটোরিয়াল

OrderedDictionary-এ IDictionaryEnumerator অবজেক্ট পান C#-এ

OrderedDictionary-এ IDictionaryEnumerator অবজেক্ট পেতে নিচের কোডটি ব্যবহার করা হয়:

উদাহরণ ১

using System; 
using System.Collections; 
using System.Collections.Specialized; 
public class Demo { 
    public static void Main() { 
        OrderedDictionary dict = new OrderedDictionary(); 
        dict.Add("1", "One"); 
        dict.Add("2", "Two"); 
        dict.Add("3", "Three"); 
        dict.Add("4", "Four"); 
        dict.Add("5", "Five"); 
        dict.Add("6", "Six"); 
        dict.Add("7", "Seven"); 
        dict.Add("8", "Eight"); 
        IDictionaryEnumerator demoEnum = dict.GetEnumerator(); 
        while (demoEnum.MoveNext()) { 
            Console.WriteLine("Key = " + demoEnum.Key + ", Value = " + demoEnum.Value); 
        } 
    } 
}

আউটপুট

এটি নিচের আউটপুটটি তৈরি করবে:

Key = 1, Value = One Key = 2, Value = Two Key = 3, Value = Three Key = 4, Value = Four Key = 5, Value = Five Key = 6, Value = Six Key = 7, Value = Seven Key = 8, Value = Eight

উদাহরণ ২

আরেকটি উদাহরণ দেখি:

using System; 
using System.Collections; 
using System.Collections.Specialized; 
public class Demo { 
    public static void Main() { 
        OrderedDictionary dict = new OrderedDictionary(); 
        dict.Add("1", "Appliances"); 
        dict.Add("2", "Supplies"); 
        dict.Add("3", "Electronics"); 
        dict.Add("4", "Clothing"); 
        dict.Add("5", "Books"); 
        dict.Add("6", "Accessories"); 
        IDictionaryEnumerator demoEnum = dict.GetEnumerator(); 
        while (demoEnum.MoveNext()) { 
            Console.WriteLine("Key = " + demoEnum.Key + ", Value = " + demoEnum.Value); 
        } 
    } 
}

আউটপুট

এটি নিচের আউটপুটটি তৈরি করবে:

Key = 1, Value = Appliances Key = 2, Value = Supplies Key = 3, Value = Electronics Key = 4, Value = Clothing Key = 5, Value = Books Key = 6, Value = Accessories
  1. C#-তে OrderedDictionary-র সব উপাদান সরাতে Clear() মেথড ব্যবহার

  2. C#-তে OrderedDictionary-র শুধুমাত্র পঠনযোগ্য (Read-Only) কপি পেতে AsReadOnly() মেথড ব্যবহার

  3. C#-এ OrderedDictionary-এ মানগুলির ICollection পাওয়া (Values প্রপার্টি)

  4. জাভাস্ক্রিপ্টে অবজেক্টের মানগুলো কীভাবে পাবেন?