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

Hashtable-এ মানগুলোর ICollection পান C#-এ

Hashtable-এ মানগুলোর ICollection পেতে নিচের কোডটি ব্যবহার করা হয়:

উদাহরণ ১

using System; 
using System.Collections; 
public class Demo { 
    public static void Main() { 
        Hashtable hash = new Hashtable(); 
        hash.Add("A", "ইলেক্ট্রনিক্স"); 
        hash.Add("B", "অ্যাপ্লায়েন্স"); 
        hash.Add("C", "পেট সাপ্লাই"); 
        hash.Add("D", "বই"); 
        hash.Add("E", "খেলনা"); 
        hash.Add("F", "ফুটওয়্যার"); 
        hash.Add("G", "পোশাক"); 
        ICollection col = hash.Values; 
        foreach(string str in col) 
            Console.WriteLine(str); 
    } 
}

আউটপুট

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

পোশাক ইলেক্ট্রনিক্স অ্যাপ্লায়েন্স পেট সাপ্লাই বই খেলনা ফুটওয়্যার

উদাহরণ ২

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

using System; 
using System.Collections; 
public class Demo { 
    public static void Main() { 
        Hashtable hash = new Hashtable(); 
        hash.Add(1, "AB"); 
        hash.Add(2, "CD"); 
        hash.Add(3, "EF"); 
        hash.Add(4, "GH"); 
        hash.Add(5, "IJ"); 
        hash.Add(6, "KL"); 
        hash.Add(7, "MN"); 
        ICollection col = hash.Values; 
        foreach(int str in col) 
            Console.WriteLine("Key = " + str + ", Value = " + hash[str]); 
    } 
}

আউটপুট

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

Key = 7, Value = MN Key = 6, Value = KL Key = 5, Value = IJ Key = 4, Value = GH Key = 3, Value = EF Key = 2, Value = CD Key = 1, Value = AB
  1. C#-এ Thread ক্লাসের প্রোপার্টিগুলো

  2. C#-এ ICollection ইন্টারফেস কী?

  3. C#-এ Hashtable ক্লাসের Values প্রোপার্টি

  4. রুবি হ্যাশ মাস্টার করুন: ডেফিনিশন, উদাহরণ এবং মূল মেথডসমূহ