概要
BitArray bitArray = new BitArray(9);
bitArray.SetAll(true);
bitArray[2] = false;
代码
using System;
using System.Collections;
using System.Collections.Generic;
namespace ConsoleApp11
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
BitArray bitArray = new BitArray(9);
bitArray.SetAll(true);
foreach(bool b in bitArray)
{
int i = b ? 1 : 0;
Console.Write(i);
}
bitArray[2] = false;
Console.WriteLine("\nbitArray[2] = false");
foreach (bool b in bitArray)
{
int i = b ? 1 : 0;
Console.Write(i);
}
Console.ReadKey();
}
}
}
运行效果