C# program to demonstrate the BitArray

Here, we are going to demonstrate the BitArray in C#.Net.
Submitted by Nidhi, on May 03, 2021

Here, we will write a simple program of BitArray class, we will create an object of BitArray and assign some bit values. And print those values.

Program:

The source code to demonstrate 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[3] = true;

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

Output:

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

C# BitArray Class Programs »





Comments and Discussions




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.