বাছাই করা তালিকায় নির্দিষ্ট কী-এর সাথে যুক্ত মান পেতে বা সেট করতে, কোডটি নিম্নরূপ -
উদাহরণ
using System; using System.Collections; public class Demo { public static void Main() { SortedList list = new SortedList (); list.Add("A", "Books"); list.Add("B", "Electronics"); list.Add("C", "Appliances"); list.Add("D", "Pet Supplies"); list.Add("E", "Clothing"); list.Add("F", "Footwear"); Console.WriteLine("Value associated with key E = "+list["E"]); list["E"] = "HDD"; Console.WriteLine("Value associated with key E [Updated] = "+list["E"]); } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেValue associated with key E = Clothing Value associated with key E [Updated] = HDD
উদাহরণ
আসুন আরেকটি উদাহরণ দেখি -
using System; using System.Collections; public class Demo { public static void Main() { SortedList list = new SortedList (); list.Add("A", "Books"); list.Add("B", "Electronics"); list.Add("C", "Appliances"); list.Add("D", "Pet Supplies"); list.Add("E", "Clothing"); list.Add("F", "Footwear"); Console.WriteLine("Value associated with key D = "+list["D"]); } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেValue associated with key D = Pet Supplies