Creates a series of masks that can be used to retrieve individual bits in a BitVector32 that is set up as bit flags.
Creates the first mask in a series of masks that can be used to retrieve individual bits in a BitVector32 that is set up as bit flags.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Function CreateMask() As Integer
[C#] public static int CreateMask();
[C++] public: static int CreateMask();
[JScript] public static function CreateMask() : int;
Creates an additional mask following the specified mask in a series of masks that can be used to retrieve individual bits in a BitVector32 that is set up as bit flags.
Supported by the .NET Compact Framework.
[Visual Basic] Overloads Public Shared Function CreateMask(Integer) As Integer
[C#] public static int CreateMask(int);
[C++] public: static int CreateMask(int);
[JScript] public static function CreateMask(int) : int;
[Visual Basic, C#, C++] The following code example shows how to create and use masks.
[Visual Basic, C#, C++] Note This example shows how to use one of the overloaded versions of CreateMask. For other examples that might be available, see the individual overload topics.
[Visual Basic] Imports System 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 'Main End Class 'SamplesBitVector32 ' This code produces the following output. ' ' Initial: BitVector32{00000000000000000000000000000000} ' myBit3 = TRUE BitVector32{00000000000000000000000000000100} ' myBit4 + myBit5 = TRUE BitVector32{00000000000000000000000000011100} ' myBit1 | myBit2 = TRUE BitVector32{00000000000000000000000000011111} [C#] 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} */ [C++] #using <mscorlib.dll> #using <system.dll> using namespace System; using namespace System::Collections::Specialized; void 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(S"Initial: \t {0}", __box(myBV)); // Sets the third bit to TRUE. myBV.Item[myBit3] = true; Console::WriteLine(S"myBit3 = TRUE \t {0}", __box(myBV)); // Combines two masks to access multiple bits at a time. myBV.Item[myBit4 + myBit5] = true; Console::WriteLine(S"myBit4 + myBit5 = TRUE \t {0}", __box(myBV)); myBV.Item[myBit1 | myBit2] = true; Console::WriteLine(S"myBit1 | myBit2 = TRUE \t {0}", __box(myBV)); } /* This code produces the following output. Initial: BitVector32 {00000000000000000000000000000000} myBit3 = TRUE BitVector32 {00000000000000000000000000000100} myBit4 + myBit5 = TRUE BitVector32 {00000000000000000000000000011100} myBit1 | myBit2 = TRUE BitVector32 {00000000000000000000000000011111} */
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
BitVector32 Structure | BitVector32 Members | System.Collections.Specialized Namespace