ArrayList-এর জন্য একটি সিঙ্ক্রোনাইজড মোড়ক তৈরি করতে, কোডটি নিম্নরূপ -
উদাহরণ
using System; using System.Collections; public class Demo { public static void Main() { ArrayList arrList = new ArrayList(); arrList.Add("AB"); arrList.Add("CD"); arrList.Add("EF"); arrList.Add("GH"); arrList.Add("IJ"); arrList.Add("KL"); Console.WriteLine("ArrayList elements..."); foreach(string str in arrList) { Console.WriteLine(str); } Console.WriteLine("ArrayList is synchronized? = "+arrList.IsSynchronized); } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেArrayList elements... AB CD EF GH IJ KL ArrayList is synchronized? = False
উদাহরণ
আসুন আরেকটি উদাহরণ দেখি -
using System; using System.Collections; public class Demo { public static void Main() { ArrayList arrList = new ArrayList(); arrList.Add("AB"); arrList.Add("CD"); arrList.Add("EF"); arrList.Add("GH"); arrList.Add("IJ"); arrList.Add("KL"); Console.WriteLine("ArrayList elements..."); foreach(string str in arrList) { Console.WriteLine(str); } Console.WriteLine("ArrayList is synchronized? = "+arrList.IsSynchronized); ArrayList arrList2 = ArrayList.Synchronized(arrList); Console.WriteLine("ArrayList is synchronized? = "+arrList2.IsSynchronized); } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেArrayList elements... AB CD EF GH IJ KL ArrayList is synchronized? = False ArrayList is synchronized? = True