本文整理汇总了VB.NET中System.Collections.BitArray.Xor方法的典型用法代码示例。如果您正苦于以下问题:VB.NET BitArray.Xor方法的具体用法?VB.NET BitArray.Xor怎么用?VB.NET BitArray.Xor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.BitArray 的用法示例。
在下文中一共展示了BitArray.Xor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Main
' 导入命名空间
Imports System.Collections
Public Class SamplesBitArray
Public Shared Sub Main()
' Creates and initializes two BitArrays of the same size.
Dim myBA1 As New BitArray(4)
Dim myBA2 As New BitArray(4)
myBA1(0) = False
myBA1(1) = False
myBA1(2) = True
myBA1(3) = True
myBA2(0) = False
myBA2(2) = False
myBA2(1) = True
myBA2(3) = True
' Performs a bitwise XOR operation between BitArray instances of the same size.
Console.WriteLine("Initial values")
Console.Write("myBA1:")
PrintValues(myBA1, 8)
Console.Write("myBA2:")
PrintValues(myBA2, 8)
Console.WriteLine()
Console.WriteLine("Result")
Console.Write("XOR:")
PrintValues(myBA1.Xor(myBA2), 8)
Console.WriteLine()
Console.WriteLine("After XOR")
Console.Write("myBA1:")
PrintValues(myBA1, 8)
Console.Write("myBA2:")
PrintValues(myBA2, 8)
Console.WriteLine()
' Performing XOR between BitArray instances of different sizes returns an exception.
Try
Dim myBA3 As New BitArray(8)
myBA3(0) = False
myBA3(1) = False
myBA3(2) = False
myBA3(3) = False
myBA3(4) = True
myBA3(5) = True
myBA3(6) = True
myBA3(7) = True
myBA1.Xor(myBA3)
Catch myException As Exception
Console.WriteLine("Exception: " + myException.ToString())
End Try
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,代码行数:71,代码来源:BitArray.Xor 输出:
Initial values
myBA1: False False True True
myBA2: False True False True
Result
XOR: False True True False
After XOR
myBA1: False True True False
myBA2: False True False True
Exception: System.ArgumentException: Array lengths must be the same.
at System.Collections.BitArray.Xor(BitArray value)
at SamplesBitArray.Main()
注:本文中的System.Collections.BitArray.Xor方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论