light

专注于基于.Net平台的服务器应用.

导航

BitVector32结构学习

Posted on 2004-08-23 12:29  light's cafe  阅读(548)  评论(0编辑  收藏  举报

using System;
using System.Windows.Forms;
using System.Collections.Specialized;

namespace Lightsoftware
{
 #region <summary>
 /// <summary>
 ///
 /// </summary>
 #endregion
 public class MyClass: Object
 {
  public static void Main(String[] args)
  {
   //1    decimal 1
   int myBit1 = BitVector32.CreateMask();
   //10   decimal 2
   int myBit2 = BitVector32.CreateMask(myBit1);
   //100  decimal 4
   int myBit3 = BitVector32.CreateMask(myBit2);
   //1000 decimal 8
   int myBit4 = BitVector32.CreateMask(myBit3);
   MessageBox.Show(String.Format("{0}, {1}, {2}, {3}", myBit1, myBit2, myBit3, myBit4));

   BitVector32.Section sectionA = BitVector32.CreateSection(3);
   BitVector32.Section sectionB = BitVector32.CreateSection(127, sectionA);
   BitVector32.Section sectionC = BitVector32.CreateSection(127, sectionB);
   BitVector32.Section sectionD = BitVector32.CreateSection(127, sectionC);
   BitVector32.Section sectionE = BitVector32.CreateSection(255, sectionD);
   // Create the sections
   // AA BBBBBBB CCCCCCC DDDDDDD EEEEEEEE
   BitVector32 word = new BitVector32(0x7fffffff);
   int A = word[sectionA];
   int B = word[sectionB];
   int C = word[sectionC];
   int D = word[sectionD];
   int E = word[sectionE];
   MessageBox.Show(String.Format("{0}, {1}, {2}, {3}", A, B, C, D, E));
  }
 }
}