C# 点阵列(BitArray)

时间:2025-02-14 13:30:02
  • using System;
  • using ;
  • namespace CollectionsApplication
  • {
  • class Program
  • {
  • static void Main(string[] args)
  • {
  • // 创建两个大小为 8 的点阵列
  • BitArray ba1 = new BitArray(8);
  • BitArray ba2 = new BitArray(8);
  • byte[] a = { 60 };
  • byte[] b = { 13 };
  • // 把值 60 和 13 存储到点阵列中
  • ba1 = new BitArray(a);
  • ba2 = new BitArray(b);
  • // ba1 的内容
  • ("Bit array ba1: 60");
  • for (int i = 0; i < ; i++)
  • {
  • ("{0, -6} ", ba1[i]);
  • }
  • ();
  • // ba2 的内容
  • ("Bit array ba2: 13");
  • for (int i = 0; i < ; i++)
  • {
  • ("{0, -6} ", ba2[i]);
  • }
  • ();
  • BitArray ba3 = new BitArray(8);
  • ba3 = (ba2);
  • // ba3 的内容
  • ("Bit array ba3 after AND operation: 12");
  • for (int i = 0; i < ; i++)
  • {
  • ("{0, -6} ", ba3[i]);
  • }
  • ();
  • ba3 = (ba2);
  • // ba3 的内容
  • ("Bit array ba3 after OR operation: 61");
  • for (int i = 0; i < ; i++)
  • {
  • ("{0, -6} ", ba3[i]);
  • }
  • ();
  • ();
  • }
  • }
  • }