using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections;

namespace ch5_11
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void button1_Click(object sender, EventArgs e)
        {

            BitArray ba1 = new BitArray(4, true);
            BitArray ba2 = new BitArray(4);
            BitArray ba3 = new BitArray(4);
            ba1.Set(0, false);
            ba1.Set(3, false);
            ba2.Set(1, true);
            ba3 = ba2.And(ba1);
            listBox1.Items.Clear();
            listBox2.Items.Clear();
            listBox3.Items.Clear();
            foreach (bool bvalue in ba1)
                listBox1.Items.Add(bvalue);
            listBox1.Items.Add("count = " + ba1.Count);
            foreach (bool bvalue in ba2)
                listBox2.Items.Add(bvalue);
            listBox2.Items.Add("count = " + ba2.Count);
            for (int i = 0; i < ba3.Count; i++)
                listBox3.Items.Add(ba3.Get(i));
            listBox3.Items.Add("count = " + ba3.Count);
        }
    }
}
