32位简单标志结构SimpleBitVector32
本结构被缀以Internal修饰,藏于System.Web.Util名称空间中。
修改后的可用代码为:
using System;
using System.Reflection;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
public struct SimpleBitVector32
{
private int data;
public SimpleBitVector32(int data)
{
this.data = data;
}
public int IntegerValue
{
get { return this.data; }
set { this.data = value; }
}
public bool this[int bit]
{
get
{
return ((this.data & bit) == bit);
}
set
{
int _data = this.data;
if (value)
{
this.data = _data | bit;
}
else
{
this.data = _data & ~bit;
}
}
}
public void Set(int bit)
{
this.data |= bit;
}
public void Clear(int bit)
{
this.data &= ~bit;
}
}
using System.Reflection;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
public struct SimpleBitVector32
{
private int data;
public SimpleBitVector32(int data)
{
this.data = data;
}
public int IntegerValue
{
get { return this.data; }
set { this.data = value; }
}
public bool this[int bit]
{
get
{
return ((this.data & bit) == bit);
}
set
{
int _data = this.data;
if (value)
{
this.data = _data | bit;
}
else
{
this.data = _data & ~bit;
}
}
}
public void Set(int bit)
{
this.data |= bit;
}
public void Clear(int bit)
{
this.data &= ~bit;
}
}
posted on 2005-06-22 00:32 birdshome 阅读(2142) 评论(1) 编辑 收藏 举报