আসুন দেখি কিভাবে Bitwise এক্সক্লুসিভ বা BitArray-এর উপাদানগুলির মধ্যে অপারেশন বাস্তবায়ন করা যায় −
উদাহরণ
using System; using System.Collections; public class Demo { public static void Main(){ BitArray arr1 = new BitArray(5); BitArray arr2 = new BitArray(5); arr1[0] = false; arr1[1] = false; arr2[0] = false; arr2[1] = true; Console.WriteLine("BitArray1 elements..."); foreach (bool res in arr1){ Console.WriteLine(res); } Console.WriteLine("\nBitArray2 elements..."); foreach (bool res in arr2){ Console.WriteLine(res); } Console.WriteLine("\nBitwise exclusive OR operation..."); IEnumerable demoEnum = arr1.Xor(arr2); foreach(Object ob in demoEnum){ Console.WriteLine(ob); } } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেBitArray1 elements... False False False False False BitArray2 elements... False True False False False Bitwise exclusive OR operation... False True False False False
উদাহরণ
এখন আরেকটি উদাহরণ দেখা যাক -
using System; using System.Collections; public class Demo { public static void Main(){ BitArray arr1 = new BitArray(5); BitArray arr2 = new BitArray(5); arr1[0] = false; arr1[1] = false; arr1[2] = false; arr1[3] = true; arr1[4] = false; arr2[0] = false; arr2[1] = true; arr2[2] = false; arr2[3] = true; arr2[4] = true; Console.WriteLine("BitArray1 elements..."); foreach (bool res in arr1){ Console.WriteLine(res); } Console.WriteLine("\nBitArray2 elements..."); foreach (bool res in arr2){ Console.WriteLine(res); } Console.WriteLine("\nBitwise exclusive OR operation..."); IEnumerable demoEnum = arr1.Xor(arr2); foreach(Object ob in demoEnum){ Console.WriteLine(ob); } } }
আউটপুট
এটি নিম্নলিখিত আউটপুট −
তৈরি করবেBitArray1 elements... False False False True False BitArray2 elements... False True False True True Bitwise exclusive OR operation... False True False False True