Set BitArray Value

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
C# Code Snippets

C# Source Code Bank

See also …
edit

Simplify setting the value of a BitArray object.

const int BIT_ARRAY_SIZE = 8;
BitArray myBits = new BitArray(BIT_ARRAY_SIZE);
 
//setting a value
for (byte x = 0; x < myBits.Count; x++)
{
  myBits[x] = (((value >> x) & 0x01) == 0x01) ? true : false;
}

Today's Deals: Electronics

Personal tools