In C # and Vb.net, is there any way without iterating over a bitarray loop to check if any true or false value continues (Dotnet 2.0)?
I doubt that you could do this without a loop under the hood (since it BitArraycan be arbitrarily long, unlike BitVector32), but if you just don't want to write it yourself:
BitArray
BitVector32
var hasAnyTrue = input.Cast<bool>().Contains(true); var hasAnyFalse = input.Cast<bool>().Contains(false);
If you use the BitArray class from System.Collections, you can use the following code to determine if something is true.
C # version
var anyTrue = myArray.Cast<bool>().Any(x => x);
Version VB.Net
Dim anyTrue = myArray.Cast(Of Boolean)().Any(Function(x) x)
, BitArray, int, long .., , 0 ( true) ( false), .
- :
bool IsTrue (int bitArray) { return bitArray != 0; } bool isFalse (int bitArray) { return bitArray != int.MinValue; }
BitArray boolean . , , BitArray , , CopyTo, int[] size (Count >> 5), ints, .
boolean
CopyTo
int[]
Count >> 5