Anybody got a packed bit vector class?

  • Thread starter Thread starter Siegfried Heintze
  • Start date Start date
S

Siegfried Heintze

I have a C# web service and I need to pass a vector of bits implemented as
an array of integers to and from my browser resident javascript client. Does
anybody have a nice class already written with overloaded operator[] that I
could use to test to see if a certain bit is set in the array?
Thanks,
Siegfried
 
Siegfried Heintze said:
I have a C# web service and I need to pass a vector of bits implemented as
an array of integers to and from my browser resident javascript client. Does
anybody have a nice class already written with overloaded operator[] that I
could use to test to see if a certain bit is set in the array?

Have a look at the BitArray class.
 
The constructor for BitArray looks good because it allows my to specify the
initial values. However, I also need to extract the bit array as an array of
ints so I can pass it to native C and pass it back as a return value to the
browser resident javascript.

I looked at athe documentation and could not figure out how to extract the
underlying representation of the bit array. I suppose I could use the
enumerator and copy it out but really wanted to pass the packed bits to
native C where I could manipulate them there as well.

Alternatively, could I pass the BitArray object to native C and have native
C manipulate it with some call backs?
 
Siegfried said:
The constructor for BitArray looks good because it allows my to specify the
initial values. However, I also need to extract the bit array as an array of
ints so I can pass it to native C and pass it back as a return value to the
browser resident javascript.

The CopyTo() method handles this exact situation.
 
Back
Top