Common members:
/* Attribute */count // read-only length // same as count, but can read/write/* Method */and () // and get () // value not () // returns the reverse or () // or set () // value setall () // All is set to the specified value XOR () // returns or
Exercise:
// (Items) [], get (), set () protected void button#click (Object sender, eventargs e) {bitarray bits = new bitarray (New bool [3] {true, false, true}); bool b1 = bits [0]; // true bool b2 = bits [1]; // false // bool b1 = bits. get (0); // bool b2 = bits. get (1); bits [0] = false; bits [1] = true; // bits. set (0, false); // bits. set (1, true); bool B11 = bits [0]; // false bool B22 = bits [1]; // true textbox1.text = string. concat (B1, "\ n", B2, "\ n", B11, "\ n", B22);} // setall () and traverse protected void button2_click (Object sender, eventargs e) {bitarray bits = new bitarray (5); string str1 = ""; foreach (bool B in bits) {str1 + = B. tostring () + ""; // false False false} bits. setall (true); string str2 = ""; foreach (bool B in bits) {str2 + = B. tostring () + ""; // true} textbox1.text = str1 + "\ n" + str2;} // count, lengthprotected void button3_click (Object sender, eventargs e) {bitarray bits = new bitarray (5); int n1 = bits. count; // 5 bits. length = 3; int n2 = bits. count; // 3 textbox1.text = string. concat (N1, "\ n", N2);} // not () protected void button4_click (Object sender, eventargs E) {bitarray bits = new bitarray (New bool [4] {true, false, true, false}); bits. not (); // false, true, false, true textbox1.text = string. format ("{0}, {1}, {2}, {3}", BITs [0], BITs [1], BITs [2], bits [3]);} // and () protected void button5_click (Object sender, eventargs e) {bitarray bits1 = new bitarray (New bool [4] {true, false, true, false}); bitarray bits2 = new bitarray (New bool [4] {true, true, false, false}); bits1.and (bits2); // true, false, false, false textbox1.text = string. format ("{0}, {1}, {2}, {3}", bits1 [0], bits1 [1], bits1 [2], bits1 [3]);} // or () protected void button6_click (Object sender, eventargs e) {bitarray bits1 = new bitarray (New bool [4] {true, false, true, false}); bitarray bits2 = new bitarray (New bool [4] {true, true, false, false}); bits1.or (bits2); // true, true, true, false textbox1.text = string. format ("{0}, {1}, {2}, {3}", bits1 [0], bits1 [1], bits1 [2], bits1 [3]);} // XOR () protected void button7_click (Object sender, eventargs e) {bitarray bits1 = new bitarray (New bool [4] {true, false, true, false}); bitarray bits2 = new bitarray (New bool [4] {true, true, false, false}); bits1.xor (bits2); // false, true, true, false textbox1.text = string. format ("{0}, {1}, {2}, {3}", bits1 [0], bits1 [1], bits1 [2], bits1 [3]);} // other <SPAN class = 'wp _ keywordlink'> cubic </span> protected void button8_click (Object sender, eventargs e) Method) {// The object contains three true bitarray bits1 = new bitarray (3, true); // when byte [] is used as the parameter, map each of its eight bytes to an element bitarray bits2 = new bitarray (New byte [3] {byte. maxvalue, byte. minvalue, byte. maxvalue}); // when int [] is used as the parameter, the 32 digits of each int are mapped to an element bitarray bits3 = new bitarray (New int [3] {Int. maxvalue, Int. minvalue, Int. maxvalue}); int n1 = bits1.length; // 3 int n2 = bits2.length; // 24 int N3 = bits3.length; // 96 string S1, S2, S3; s1 = S2 = S3 = ""; foreach (bool B in bits1) {S1 = string. concat (S1, convert. tobyte (B);} // 111 foreach (bool B in bits2) {S2 = string. concat (S2, convert. tobyte (B);} // 11111111 // 00000000 // 11111111 foreach (bool B in bits3) {S3 = string. concat (S3, convert. tobyte (B);} // 11111111111111111111111111111110 // 00000000000000000000000000000001 // 11111111111111111111111111111110 // textbox1.text = string. concat (N1, "\ n", N2, "\ n", N3, "\ n", S1, "\ n", S2, "\ n ", s3 );}