Share via


how to create an array of boolean with default value true

Question

Thursday, May 22, 2008 9:16 AM

 

Hello

 

I need to create an array as boolean but i would like to have the default value set to true instead of false.

 

Is there a simple way to do that without changing the values manualy?

 

cheers

All replies (2)

Thursday, May 22, 2008 9:49 AM âś…Answered

have you tried using the BitArray class in the System.Collections namespace?

 

you can give it the number of elements to create and the default value for them:

 

BitArray myBitArray = new BitArray(4, true);

 

is this what you are after?


Thursday, May 22, 2008 12:47 PM

Depending on how large your array is, this may not be a practical solution:

dim b() as Boolean = {True,True,True,True,True,True,True)