BitVector32.CreateMask 方法  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建一系列屏蔽,这些屏蔽可以用于检索作为位标志设置的 BitVector32 中的单个位。
重载
| CreateMask() | 创建一系列屏蔽中的第一个屏蔽,该系列屏蔽可以用于检索作为位标志设置的 BitVector32 中的单个位。 | 
| CreateMask(Int32) | 在一系列屏蔽中的指定屏蔽后面再创建一个屏蔽,该系列屏蔽可以用于检索作为位标志设置的 BitVector32 中的单个位。 | 
示例
下面的代码示例演示如何创建和使用掩码。
#using <system.dll>
using namespace System;
using namespace System::Collections::Specialized;
int main()
{
   // Creates and initializes a BitVector32 with all bit flags set to FALSE.
   BitVector32 myBV;
   // Creates masks to isolate each of the first five bit flags.
   int myBit1 = BitVector32::CreateMask();
   int myBit2 = BitVector32::CreateMask( myBit1 );
   int myBit3 = BitVector32::CreateMask( myBit2 );
   int myBit4 = BitVector32::CreateMask( myBit3 );
   int myBit5 = BitVector32::CreateMask( myBit4 );
   Console::WriteLine( "Initial:               \t {0}", myBV );
   // Sets the third bit to TRUE.
   myBV[ myBit3 ] = true;
   Console::WriteLine( "myBit3 = TRUE          \t {0}", myBV );
   // Combines two masks to access multiple bits at a time.
   myBV[ myBit4 + myBit5 ] = true;
   Console::WriteLine( "myBit4 + myBit5 = TRUE \t {0}", myBV );
   myBV[ myBit1 | myBit2 ] = true;
   Console::WriteLine( "myBit1 | myBit2 = TRUE \t {0}", myBV );
}
/*
This code produces the following output.
Initial:                BitVector32 {00000000000000000000000000000000}
myBit3 = TRUE           BitVector32 {00000000000000000000000000000100}
myBit4 + myBit5 = TRUE  BitVector32 {00000000000000000000000000011100}
myBit1 | myBit2 = TRUE  BitVector32 {00000000000000000000000000011111}
*/
using System;
using System.Collections.Specialized;
public class SamplesBitVector32  {
   public static void Main()  {
      // Creates and initializes a BitVector32 with all bit flags set to FALSE.
      BitVector32 myBV = new BitVector32( 0 );
      // Creates masks to isolate each of the first five bit flags.
      int myBit1 = BitVector32.CreateMask();
      int myBit2 = BitVector32.CreateMask( myBit1 );
      int myBit3 = BitVector32.CreateMask( myBit2 );
      int myBit4 = BitVector32.CreateMask( myBit3 );
      int myBit5 = BitVector32.CreateMask( myBit4 );
      Console.WriteLine( "Initial:               \t{0}", myBV.ToString() );
      // Sets the third bit to TRUE.
      myBV[myBit3] = true;
      Console.WriteLine( "myBit3 = TRUE          \t{0}", myBV.ToString() );
      // Combines two masks to access multiple bits at a time.
      myBV[myBit4 + myBit5] = true;
      Console.WriteLine( "myBit4 + myBit5 = TRUE \t{0}", myBV.ToString() );
      myBV[myBit1 | myBit2] = true;
      Console.WriteLine( "myBit1 | myBit2 = TRUE \t{0}", myBV.ToString() );
   }
}
/*
This code produces the following output.
Initial:                BitVector32{00000000000000000000000000000000}
myBit3 = TRUE           BitVector32{00000000000000000000000000000100}
myBit4 + myBit5 = TRUE  BitVector32{00000000000000000000000000011100}
myBit1 | myBit2 = TRUE  BitVector32{00000000000000000000000000011111}
*/
Imports System.Collections.Specialized
Public Class SamplesBitVector32
   Public Shared Sub Main()
      ' Creates and initializes a BitVector32 with all bit flags set to FALSE.
      Dim myBV As New BitVector32(0)
      
      ' Creates masks to isolate each of the first five bit flags.
      Dim myBit1 As Integer = BitVector32.CreateMask()
      Dim myBit2 As Integer = BitVector32.CreateMask(myBit1)
      Dim myBit3 As Integer = BitVector32.CreateMask(myBit2)
      Dim myBit4 As Integer = BitVector32.CreateMask(myBit3)
      Dim myBit5 As Integer = BitVector32.CreateMask(myBit4)
      Console.WriteLine("Initial:               " + ControlChars.Tab + "{0}", myBV.ToString())
      
      ' Sets the third bit to TRUE.
      myBV(myBit3) = True
      Console.WriteLine("myBit3 = TRUE          " + ControlChars.Tab + "{0}", myBV.ToString())
      
      ' Combines two masks to access multiple bits at a time.
      myBV((myBit4 + myBit5)) = True
      Console.WriteLine("myBit4 + myBit5 = TRUE " + ControlChars.Tab + "{0}", myBV.ToString())
      myBV((myBit1 Or myBit2)) = True
      Console.WriteLine("myBit1 | myBit2 = TRUE " + ControlChars.Tab + "{0}", myBV.ToString())
   End Sub
End Class
' This code produces the following output.
'
' Initial:                BitVector32{00000000000000000000000000000000}
' myBit3 = TRUE           BitVector32{00000000000000000000000000000100}
' myBit4 + myBit5 = TRUE  BitVector32{00000000000000000000000000011100}
' myBit1 | myBit2 = TRUE  BitVector32{00000000000000000000000000011111}
CreateMask()
- Source:
- BitVector32.cs
- Source:
- BitVector32.cs
- Source:
- BitVector32.cs
创建一系列屏蔽中的第一个屏蔽,该系列屏蔽可以用于检索作为位标志设置的 BitVector32 中的单个位。
public:
 static int CreateMask();public static int CreateMask ();static member CreateMask : unit -> intPublic Shared Function CreateMask () As Integer返回
一个屏蔽,它隔离 BitVector32 中的第一个位标志。
注解
使用 CreateMask() 创建系列中的第一个掩码,并 CreateMask(int) 用于所有后续掩码。
可以创建多个掩码来引用同一位标志。
生成的掩码仅隔离 中的 BitVector32一个位标志。 可以使用按位 OR 操作组合掩码,以创建隔离 中的多个位标志的 BitVector32掩码。
在设置为节的 上使用 BitVector32 掩码可能会导致意外结果。
此方法是 O (1) 操作。
适用于
CreateMask(Int32)
- Source:
- BitVector32.cs
- Source:
- BitVector32.cs
- Source:
- BitVector32.cs
在一系列屏蔽中的指定屏蔽后面再创建一个屏蔽,该系列屏蔽可以用于检索作为位标志设置的 BitVector32 中的单个位。
public:
 static int CreateMask(int previous);public static int CreateMask (int previous);static member CreateMask : int -> intPublic Shared Function CreateMask (previous As Integer) As Integer参数
- previous
- Int32
指示前一个位标志的屏蔽。
返回
一个屏蔽,它隔离 BitVector32 中 previous 所指向的位标志后面的位标志。
例外
              previous 指示 BitVector32 中的最后一个位标志。
注解
使用 CreateMask() 创建系列中的第一个掩码,并 CreateMask(int) 用于所有后续掩码。
可以创建多个掩码来引用同一位标志。
生成的掩码仅隔离 中的 BitVector32一个位标志。 可以使用按位 OR 操作组合掩码,以创建隔离 中的多个位标志的 BitVector32掩码。
在设置为节的 上使用 BitVector32 掩码可能会导致意外结果。
此方法是 O (1) 操作。