C# program to perform the bitwise AND operation between BitArray elements (BitArray.And() Method)

We are writing every article every day. C# program to perform the bitwise AND operation between BitArray elements (BitArray.And() Method) Let’s see clearly about this article today.

C# program to perform the bitwise AND operation between BitArray elements (BitArray.And() Method)

C# program to perform the bitwise AND operation between BitArray elements (BitArray.And() Method)

using System;
using System.Collections;

class BitArrayEx
{
    //Entry point of Program
    static public void Main()
    {
        //Creation of BitArray objects
        BitArray bitArr1 = new BitArray(3);
        BitArray bitArr2 = new BitArray(3);
        BitArray bitArr3;

        int index = 0;

        bitArr1[0] = true;
        bitArr1[1] = false;
        bitArr1[2] = true;

        bitArr2[0] = true;
        bitArr2[1] = true;
        bitArr2[2] = false;

        bitArr3 = bitArr1.And(bitArr2);


        Console.WriteLine("Elements of BitArray after Bitwise And Operation:");
        for (index = 0; index < bitArr3.Length; index++)
        {
            Console.WriteLine("\tIndex "+index + ": "+bitArr3.Get(index));
        }
    }
}
Elements of BitArray after Bitwise And Operation:
        Index 0: True
        Index 1: False
        Index 2: False
Press any key to continue . . .

Final Words

C# program to perform the bitwise AND operation between BitArray elements (BitArray.And() Method) We hope you find this article useful. Let us know if you have any doubts.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment