|
-
May 11th, 2003, 01:47 PM
#1
Thread Starter
Member
BitArray
I have a BitArray of 8 bits and I want to know the total value of the bits as if it were a byte.
Code:
Dim Mask As New BitArray(8, True)
Mask(0) = False
I'd like to now put them 8 bits (1 byte) into a byte varible, something like:
Code:
Dim MyByte as byte = mask
Then in the above example MyByte would = 254
Basically, assigning the 8 bits to a byte and being able to get the total value of that byte (which in this case would be the total of the 8 bits).
-
May 11th, 2003, 08:48 PM
#2
Lively Member
You can use the CopyTo method to copy the bits to a one-byte-long byte array. That single byte will have the value you seek:
VB Code:
Dim Mask As New BitArray(8, True)
Mask(0) = False
Dim ByteArray(0) As Byte
Mask.CopyTo(ByteArray, 0)
Dim MyByte As Byte = ByteArray(0)
-
May 13th, 2003, 04:37 AM
#3
Thread Starter
Member
That works great, thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|