- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the BitArray class in C#?
The BitArray class is used when you need to store the bits but do not know the number of bits in advance.
The following are some of the properties of the BitArray class in C# −
Sr.No. | Property & Description |
---|---|
1 | Count Gets the number of elements contained in the BitArray. |
2 | IsReadOnly Gets a value indicating whether the BitArray is read-only. |
3 | Item Gets or sets the value of the bit at a specific position in the BitArray. |
4 | Length Gets or sets the number of elements in the BitArray. |
Let us see how to work with IsReadOnly property in C#.
With IsReadOnly class, you can get a value indicating whether the BitArray is read-only or not. ReadOnly will not allow you to add new elements to the BitArray.
The following is our example stating how to use the IsReadOnly property of BitArray class in C# −
Example
using System; using System.Collections; namespace Demo { class Program { static void Main(string[] args) { BitArray ba1 = new BitArray(5); BitArray ba2 = new BitArray(5); byte[] a = { 90 }; byte[] b = { 30 }; ba1 = new BitArray(a); ba2 = new BitArray(b); Console.WriteLine("Bit array ba1: 60"); for (int i = 0; i < ba1.Count; i++) { Console.Write("{0, -4} ", ba1[i]); } Console.WriteLine(); Console.WriteLine("IsReadOnly = " + ba1.IsReadOnly); Console.WriteLine("IsReadOnly = " + ba2.IsReadOnly); Console.ReadKey(); } } }
- Related Articles
- What is the IsReadOnly property of BitArray class in C#?
- What is the Length property of BitArray class in C#?
- What is the Count property of BitArray class in C#?
- What is the Item property of BitArray class in C#?
- BitArray Class in C#
- What is index-based I/O BitArray collection in C#?
- Check if the BitArray is read-only in C#
- Enumerator that iterates through the BitArray in C#
- What is the Queue class in C#?
- What is the Hashtable class in C#?
- What is the ArrayList class in C#?
- What is the SortedList class in C#?
- What is the Stack class in C#?
- What is the Mutex class in C#?
- Number of elements contained in the BitArray in C#?

Advertisements