|
|
|
The System.Collections.Specialized.BitVector32 structure can be used to store up to 32 boolean values, or a set of small integers that can take up to 32 consecutive bits. The BitVector32 is similar to the BitArray class, in that it can hold boolean values that take only one bit each, yet it is more efficient because it is a structure instead of a class.
The simplest way to use a BitVector32 structure is to hold up to 32 boolean values: |
You can also pass a 32-bit integer to the constructor to initialize all the elements in one pass. For example: |
To define a BitVector32 that is subdivided in sections that are longer than 1 bit you must create one or more BitVector32.Section objects, and use them when you later read and write individual elements. You define a section by means of the BitVector32.CreateSection shared method, that takes the highest integer you want to store in that section and (for all sections after the 1st one) the previous section. Here's a complete example: |
Click here to copy the following block | Dim bv As New BitVector32()
Dim se1 As BitVector32.Section = BitVector32.CreateSection(15) Dim se2 As BitVector32.Section = BitVector32.CreateSection(31, se1) Dim se3 As BitVector32.Section = BitVector32.CreateSection(63, se2)
bv(se1) = 10 bv(se2) = 20 bv(se3) = 40
Console.WriteLine(bv(se1)) Console.WriteLine(bv(se2)) Console.WriteLine(bv(se3)) |
The Data property sets or returns the internal 32-bit value; you can use this property to save the value into a database field: |
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|