本文整理匯總了VB.NET中System.Collections.Specialized.BitVector32結構體的典型用法代碼示例。如果您正苦於以下問題:VB.NET BitVector32結構體的具體用法?VB.NET BitVector32怎麽用?VB.NET BitVector32使用的例子?那麽, 這裏精選的結構體代碼示例或許可以為您提供幫助。
在下文中一共展示了BitVector32結構體的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: SamplesBitVector32
' 導入命名空間
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)
' Sets the alternating bits to TRUE.
Console.WriteLine("Setting alternating bits to TRUE:")
Console.WriteLine(" Initial: {0}", myBV.ToString())
myBV(myBit1) = True
Console.WriteLine(" myBit1 = TRUE: {0}", myBV.ToString())
myBV(myBit3) = True
Console.WriteLine(" myBit3 = TRUE: {0}", myBV.ToString())
myBV(myBit5) = True
Console.WriteLine(" myBit5 = TRUE: {0}", myBV.ToString())
End Sub
End Class
輸出:
Setting alternating bits to TRUE: Initial: BitVector32{00000000000000000000000000000000} myBit1 = TRUE: BitVector32{00000000000000000000000000000001} myBit3 = TRUE: BitVector32{00000000000000000000000000000101} myBit5 = TRUE: BitVector32{00000000000000000000000000010101}
示例2: SamplesBitVector32
' 導入命名空間
Imports System.Collections.Specialized
Public Class SamplesBitVector32
Public Shared Sub Main()
' Creates and initializes a BitVector32.
Dim myBV As New BitVector32(0)
' Creates four sections in the BitVector32 with maximum values 6, 3, 1, and 15.
' mySect3, which uses exactly one bit, can also be used as a bit flag.
Dim mySect1 As BitVector32.Section = BitVector32.CreateSection(6)
Dim mySect2 As BitVector32.Section = BitVector32.CreateSection(3, mySect1)
Dim mySect3 As BitVector32.Section = BitVector32.CreateSection(1, mySect2)
Dim mySect4 As BitVector32.Section = BitVector32.CreateSection(15, mySect3)
' Displays the values of the sections.
Console.WriteLine("Initial values:")
Console.WriteLine(ControlChars.Tab + "mySect1: {0}", myBV(mySect1))
Console.WriteLine(ControlChars.Tab + "mySect2: {0}", myBV(mySect2))
Console.WriteLine(ControlChars.Tab + "mySect3: {0}", myBV(mySect3))
Console.WriteLine(ControlChars.Tab + "mySect4: {0}", myBV(mySect4))
' Sets each section to a new value and displays the value of the BitVector32 at each step.
Console.WriteLine("Changing the values of each section:")
Console.WriteLine(ControlChars.Tab + "Initial: " + ControlChars.Tab + "{0}", myBV.ToString())
myBV(mySect1) = 5
Console.WriteLine(ControlChars.Tab + "mySect1 = 5:" + ControlChars.Tab + "{0}", myBV.ToString())
myBV(mySect2) = 3
Console.WriteLine(ControlChars.Tab + "mySect2 = 3:" + ControlChars.Tab + "{0}", myBV.ToString())
myBV(mySect3) = 1
Console.WriteLine(ControlChars.Tab + "mySect3 = 1:" + ControlChars.Tab + "{0}", myBV.ToString())
myBV(mySect4) = 9
Console.WriteLine(ControlChars.Tab + "mySect4 = 9:" + ControlChars.Tab + "{0}", myBV.ToString())
' Displays the values of the sections.
Console.WriteLine("New values:")
Console.WriteLine(ControlChars.Tab + "mySect1: {0}", myBV(mySect1))
Console.WriteLine(ControlChars.Tab + "mySect2: {0}", myBV(mySect2))
Console.WriteLine(ControlChars.Tab + "mySect3: {0}", myBV(mySect3))
Console.WriteLine(ControlChars.Tab + "mySect4: {0}", myBV(mySect4))
End Sub
End Class
輸出:
Initial values: mySect1: 0 mySect2: 0 mySect3: 0 mySect4: 0 Changing the values of each section: Initial: BitVector32{00000000000000000000000000000000} mySect1 = 5: BitVector32{00000000000000000000000000000101} mySect2 = 3: BitVector32{00000000000000000000000000011101} mySect3 = 1: BitVector32{00000000000000000000000000111101} mySect4 = 9: BitVector32{00000000000000000000001001111101} New values: mySect1: 5 mySect2: 3 mySect3: 1 mySect4: 9