I wrote a code in AS3 which allowed me to check if a particular number of things were true…
If (true + false + true + true + false + true + true < 4)
{
}
When i tried rewriting in C#, it tells me i cannot add type bool and bool. Is the best way of doing this to rewrite it like this? Or is there some simpler work around?
If ((true?1:0) + (false?1:0) + (true?1:0) + (true?1:0) + (false?1:0) + (true?1:0) + (true?1:0) < 4)
{
}
Try using
IEnumerable<T>.Count(Func<T,bool>)fromSystem.Linq, withTasbool, on aparamsmethod parameter.Usage
You can also introduce a
thisextension method:Usage