Q:

C# program to get the value of the bit at a specific position in the BitArray (BitArray.Get() Method)

belongs to collection: C# BitArray Class Programs

0

C# program to get the value of the bit at a specific position in the BitArray (BitArray.Get() Method)

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program:

The source code to get the value of the bit at a specific position in the BitArray is given below. The given program is compiled and executed successfully.

using System;
using System.Collections;

class BitArrayEx
{
    //Entry point of Program
    static public void Main()
    {
        //Creation of BitArray object
        BitArray bitArr = new BitArray(5);

        int index = 0;

        bitArr[0] = true;
        bitArr[2] = true;
        bitArr[3] = true;

        Console.WriteLine("Elements of BitArray:");
        for (index = 0; index < bitArr.Length; index++)
        {
            Console.WriteLine("\tIndex "+index + ": "+bitArr.Get(index));
        }
    }
}

Output:

Elements of BitArray:
        Index 0: True
        Index 1: False
        Index 2: True
        Index 3: True
        Index 4: False
Press any key to continue . . .

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# program to perform the bitwise AND operation be... >>
<< C# program to demonstrate the BitArray...