I would like to have a LINQ statement that calls the property IsValid.
If all elements returned true, I want the statement to return true as well.
How can it be done?
views:
52answers:
3
A:
I am not sure if this is what you are looking for, but take a look at this article. http://www.albahari.com/nutshell/predicatebuilder.aspx
Ryk
2010-06-30 23:58:58
Interesting article. Not directly related to what I'm asking.
the_drow
2010-07-01 00:09:20
+3
A:
You need the Enumerable.All<TSource> method:
bool everythingsZen = anEnumerable.All(a => a.IsValid);
jball
2010-06-30 23:59:51
IsValid is a "property", in the OP's question. This would mean "a => a.IsValid" (no method here).
Reed Copsey
2010-07-01 00:03:56