⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample34.cs

📁 C#函数手册
💻 CS
字号:
namespace apiBook
{
	using System;
	using System.Collections;
	public class TestBitArrayClass
	{
		public static void Main()  
		{
			TestBitArrayClass t=new TestBitArrayClass();
			BitArray testArray = new BitArray( 5 );
			Console.WriteLine( "BitArray对象的所有元素:" );
			t.PrintValues( testArray,',' );
			testArray.SetAll( true );
			//使用SetAll方法设置所有元素的值
			Console.WriteLine( "当全部设置为true后" );
			t.PrintValues( testArray ,',');
			testArray.Set( 1, false );
			//使用Set方法设置某个元素的值
			testArray.Set( 3, false );
			Console.WriteLine( "将下标为1、3的元素设为false" );
			t.PrintValues( testArray ,',');
			for(int i=0;i<testArray.Length;i++)
			{
				Console.WriteLine("第"+i+"元素:"+testArray.Get(i));
				//使用Get方法获取具体位置元素的值
			}
			Console.ReadLine();
		}
		public void PrintValues( IEnumerable testBit,char separator )  
		{
			System.Collections.IEnumerator testEnumerator = testBit.GetEnumerator();
			while ( testEnumerator.MoveNext() )
				Console.Write( ""+testEnumerator.Current+separator);
			Console.WriteLine();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -