当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET BitArray类代码示例

本文整理汇总了VB.NET中System.Collections.BitArray的典型用法代码示例。如果您正苦于以下问题:VB.NET BitArray类的具体用法?VB.NET BitArray怎么用?VB.NET BitArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BitArray类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: SamplesBitArray

' 导入命名空间
Imports System.Collections

Public Class SamplesBitArray

    Public Shared Sub Main()

        ' Creates and initializes several BitArrays.
        Dim myBA1 As New BitArray(5)

        Dim myBA2 As New BitArray(5, False)

        Dim myBytes() As Byte = {1, 2, 3, 4, 5}
        Dim myBA3 As New BitArray(myBytes)

        Dim myBools() As Boolean = {True, False, True, True, False}
        Dim myBA4 As New BitArray(myBools)

        Dim myInts() As Integer = {6, 7, 8, 9, 10}
        Dim myBA5 As New BitArray(myInts)

        ' Displays the properties and values of the BitArrays.
        Console.WriteLine("myBA1")
        Console.WriteLine("   Count:    {0}", myBA1.Count)
        Console.WriteLine("   Length:   {0}", myBA1.Length)
        Console.WriteLine("   Values:")
        PrintValues(myBA1, 8)

        Console.WriteLine("myBA2")
        Console.WriteLine("   Count:    {0}", myBA2.Count)
        Console.WriteLine("   Length:   {0}", myBA2.Length)
        Console.WriteLine("   Values:")
        PrintValues(myBA2, 8)

        Console.WriteLine("myBA3")
        Console.WriteLine("   Count:    {0}", myBA3.Count)
        Console.WriteLine("   Length:   {0}", myBA3.Length)
        Console.WriteLine("   Values:")
        PrintValues(myBA3, 8)

        Console.WriteLine("myBA4")
        Console.WriteLine("   Count:    {0}", myBA4.Count)
        Console.WriteLine("   Length:   {0}", myBA4.Length)
        Console.WriteLine("   Values:")
        PrintValues(myBA4, 8)

        Console.WriteLine("myBA5")
        Console.WriteLine("   Count:    {0}", myBA5.Count)
        Console.WriteLine("   Length:   {0}", myBA5.Length)
        Console.WriteLine("   Values:")
        PrintValues(myBA5, 8)

    End Sub

    Public Shared Sub PrintValues(myList As IEnumerable, myWidth As Integer)
        Dim i As Integer = myWidth
        Dim obj As [Object]
        For Each obj In  myList
            If i <= 0 Then
                i = myWidth
                Console.WriteLine()
            End If
            i -= 1
            Console.Write("{0,8}", obj)
        Next obj
        Console.WriteLine()
    End Sub

End Class
开发者ID:VB.NET开发者,项目名称:System.Collections,代码行数:69,代码来源:BitArray

输出:

myBA1
Count:    5
Length:   5
Values:
False   False   False   False   False
myBA2
Count:    5
Length:   5
Values:
False   False   False   False   False
myBA3
Count:    40
Length:   40
Values:
True   False   False   False   False   False   False   False
False    True   False   False   False   False   False   False
True    True   False   False   False   False   False   False
False   False    True   False   False   False   False   False
True   False    True   False   False   False   False   False
myBA4
Count:    5
Length:   5
Values:
True   False    True    True   False
myBA5
Count:    160
Length:   160
Values:
False    True    True   False   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False
True    True    True   False   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False    True   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False
True   False   False    True   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False
False    True   False    True   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False
False   False   False   False   False   False   False   False


注:本文中的System.Collections.BitArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。