algorithmic modeling for Rhino
Hi, all!!
How can I check with a list of booleans in C#?
For example, if I have a list of booleans,
(true, true, true, false)
then, is there a way to check it with all and pass 'false'?
I guess I can use '&&' conditions...but thiese number of booleans will be varying.
Tags:
Hi YJ,
public bool AllBooleansTrue(List<bool> blist)
{
for (int i = 0; i < blist.Count; i++)
{
if (!blist[i]) { return false; }
}
return true;
}
You could also use a Predicate and the TrueForAll() method on List<> to check this.
Finally, to accomplish this without scripting, use the MassAddition component to sum all Booleans together, and if the final result equals the number of items, all of them were True.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by