|
Hello, I was wondering if it was possible to hold an array of booleans and then be able to check if they are false or not in C#. What i wanted to do is have an if statement that says if there all false, then set one true. The thing is im not very familiar with arrays so can someone point me in the right direction for what im looking for? Thanks For The Help :)
(comments are locked)
|
|
just use a for loop: is that what you want to do? It gives me the error "bool[] does not contain a definition for 'length' and no extension method 'length' of type bool[] could be found" Then it says "are you missing a directive or an assembly reference"
Feb 21 '12 at 04:21 PM
TripodGRANNE
Yes, it should be
Feb 21 '12 at 04:45 PM
ti89TProgrammer
Awesome it works now, thanks for the help guys :)
Feb 21 '12 at 04:48 PM
TripodGRANNE
oh right, sorry for that ^.^ now everybody knows that i am a java guy ;) glad it worked
Feb 21 '12 at 05:57 PM
ZweiD
(comments are locked)
|
|
This is quite a good tutorial for arrays in C#. See if it helps you.
(comments are locked)
|
|
The easiest thing to do is use LINQ. (using System.Linq; at the top of your code):
(comments are locked)
|
|
You can use one of a couple of methods in the The list of booleans more compactly as a However, if you don’t need to store more than 32 values in the list, then you can achieve greater efficiency by scrapping the use of an actual array completely and instead using an instance of the In this case, if you need to store fewer than 32 values, then you might need an extra variable to store the logical count of booleans.
(comments are locked)
|
