- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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 Item property of BitArray class in C#?
The Item property of the BitArray class gets or sets the value of the bit at a specific position in the BitArray.
Use the keyword to define the indexers instead of implementing the Item property. To access an element, use the mycollection[index].
The following is the implementation of BitArray class Item property −
Example
using System; using System.Collections; class Demo { static void Main() { bool[] arr = new bool[5]; arr[0] = true; arr[1] = true; arr[2] = false; arr[3] = false; BitArray bArr = new BitArray(arr); foreach (bool b in bArr) { Console.WriteLine(b); } bool str = arr[1]; Console.WriteLine("Value of 2nd element:"+str); } }
Output
True True False False False Value of 2nd element:True
Advertisements