|
|
|
.NET Boolean values require 4 bytes each, as opposed to the 2 byte taken under previous VB versions. When creating very large Boolean arrays this extra memory impacts negatively on the application's performance. The .NET Framework offers a specialized class, the System.Collection.BitArray class, which lets you store a number of boolean values as if it were a regular array, yet it takes only 1 bit for each element.
You pass the capacity of the array - that is, the number of Boolean values you want to store - to the BitArray's constructor, and then you write and read its elements as if it were a regular array: |
All the elements in a freshly created BitArray are initialized to False, but you can set them to True by using the following constructor |
or with the SetAll method |
You can also pass a true Boolean array to the BitArray constructor, so that each element in the BitArray is initialized with the corresponding element in the original Boolean array. Finally, you can perform bitwise operations on all the members of a BitArray by means of Not, And, Or, and Xor methods. All these methods (except Not) take another BitArray as an argument, so that all the elements of the current BitArray are combined with the corresponding element of the other BitArray according to the specified operation: |
|
|
|
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 ) |
|
|