bitlist.cs

来自「c#设计模式随书源码 c#设计模式随书源码」· CS 代码 · 共 25 行

CS
25
字号
using System;

namespace indexers
{
	/// <summary>
	/// Summary description for BitList.
	/// </summary>
	public class BitList
	{
		private int number;
		public BitList(string snum) {
			number = Convert.ToInt32 (snum);
		}
		//------
		// here is an indexer that
		//returns the i-th bit of a value
		public int this[int index] {
			get{
				int val = number >> index;
				return val & 1;
			}
		}
	}
}

⌨️ 快捷键说明

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