I want to check if any of the items in a list has a field set to true
at the moment I do this:
bool isPaid = visit.Referrals.Exists(delegate(AReferral r)
{
return r.IsPaidVisit;
});
How can I do this using Linq
might be trivial to some but can't figure if now.
using System.Linq;
...
bool isPaid = visit.Referrals.Any(r => r.IsPaidVisit);
but why use the Linq library when you can do the following:
bool isPaid = visit.Referrals.Exists(r => r.IsPaidVisit);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With