鸟食轩

 Microsoft .NET[C#] MVP 2003
随笔 - 424, 文章 - 233, 评论 - 5417, 引用 - 344
数据加载中……

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;
    }

}

 

posted on 2005-06-22 00:32 birdshome 阅读(1572) 评论(1)  编辑 收藏 所属分类: .NET的私有工具类

评论

#1楼    回复  引用  查看    

请问这可以用来做什么
2007-09-12 16:53 | 留恋星空      

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2005-07-13 01:34 编辑过


相关链接: