How can I reverse a whole array of Booleans? Is there a simple way of doing this?
Thanks.
Printable View
How can I reverse a whole array of Booleans? Is there a simple way of doing this?
Thanks.
vb Code:
for i as integer = 0 to myarray.length - 1 myarray(i) = Not myarray(i) next
Something like that should work and is fairly simple.
Justin
try this:
vb Code:
yourBooleanArray = Array.ConvertAll(yourBooleanArray, Function(b) Not b)
One important point to note is that this doesn't actually affect the original array object, but rather create a new array object and assign that to the original variable. Generally speaking, that's not going to be an issue but, if you have some other reference to the original array somewhere, that will not be affected.