Dim MyShort As uShort = 32 Dim oByteArray As New System.Collections.BitArray(System.BitConverter.GetBytes(MyShort))
Here is what the above code is Doing:
1. Create a new BitArray object, passing in a byte array.
2. The byte array is created by calling the GetBytes method of the BitConverter class.
3. The GetBytes method takes a value and returns a byte array.
4. The value is a short, which is a 16-bit integer.
5. The short is set to 32.
6. The BitArray object is stored in a variable named oByteArray.
The BitArray object is a collection of bits. It has a Count property that returns the number of bits in the array.