Converting BitArray to Int and Int to BitArray
Author Message
Converting BitArray to Int and Int to BitArray

Converting BitArray to Int and Int to BitArray

Can anyone help?

Thanks
J.F. Larente
United Way/Centraide Ottawa

Sun, 03 Jul 2005 04:06:32 GMT
Converting BitArray to Int and Int to BitArray
Jean-Fran?ois,

Quote:
>Converting BitArray to Int

Dim i(0) As Integer
YourBitArray.CopyTo(i, 0)

Adjust the array size to be large enough to have room for the BitArray
bits.

Quote:
>and Int to BitArray

YourBitArray = New BitArray(New Integer() {YourInt})

Mattias

===

http://www.msjogren.net/dotnet/

Sun, 03 Jul 2005 04:44:53 GMT
Converting BitArray to Int and Int to BitArray
Thank you...
It's starting to make sense to me.

Now, I'll tell you the point of my excercise so that you can maybe further
help me.
Maybe I'm in left field with this method.

I have 16 departments which are assigned to a position in a 16 bit binary
string.
I have a read and a write field

So, if all 16 departments are allowed to read, the 16 bits would all be set
to true.

If department 15 ONLY was allowed to write, the second-last bit would be set
to true (a value of int 2)

Anyway, I have a hard time explaning what I want...

I store an int in the DB and use a 16 bit int to verify access rights.

Thanks if you understand!

J.F.

Quote:
> Jean-Fran?ois,

> >Converting BitArray to Int

> Dim i(0) As Integer
> YourBitArray.CopyTo(i, 0)

> Adjust the array size to be large enough to have room for the BitArray
> bits.

> >and Int to BitArray

> YourBitArray = New BitArray(New Integer() {YourInt})

> Mattias

> ===

> http://www.msjogren.net/dotnet/