C # lattice column (BitArray)

Source: Internet
Author: User

A compressed array of managed locations that represents the Boolean value, True for open (1), and false to indicate that the bit is off (0).

Bitmap columns are used when you need to store bits, but do not know the number of bits beforehand.

Using system;using System.collections;namespace collectionsapplication{class Program {static void Main (Stri            Ng[] (args) {//Create two lattice columns with a size of 8 BitArray Ba1 = new BitArray (8);            BitArray Ba2 = new BitArray (8);            Byte[] A = {60};                        Byte[] B = {13};            Store the values 60 and 13 in the point array Ba1 = new BitArray (a);            Ba2 = new BitArray (b);            Ba1 content Console.WriteLine ("Bit array ba1:60"); for (int i = 0; i < Ba1. Count;            i++) {Console.Write ("{0,-6}", Ba1[i]);                        } Console.WriteLine ();            Ba2 content Console.WriteLine ("Bit array ba2:13"); for (int i = 0; i < Ba2. Count;            i++) {Console.Write ("{0,-6}", Ba2[i]);                                   } Console.WriteLine ();            BitArray Ba3 = new BitArray (8); Ba3 = Ba1. and (BA2);            Ba3 content Console.WriteLine ("Bit array ba3 after and Operation:12"); for (int i = 0; i < Ba3. Count;            i++) {Console.Write ("{0,-6}", Ba3[i]);            } Console.WriteLine (); Ba3 = Ba1.            or (BA2);            Ba3 content Console.WriteLine ("Bit array ba3 after OR operation:61"); for (int i = 0; i < Ba3. Count;            i++) {Console.Write ("{0,-6}", Ba3[i]);                        } Console.WriteLine ();        Console.readkey (); }    }}
<a target=_blank href= "http://www.w3cschool.cc/csharp/csharp-bitarray.html" >http://www.w3cschool.cc/csharp /csharp-bitarray.html</a>



C # lattice column (BitArray)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.