I want to check if any of the items in the list has a field set to true
true
I'm currently doing this:
bool isPaid = visit.Referrals.Exists(delegate(AReferral r) { return r.IsPaidVisit; });
How can I do this using Linq may be trivial for some, but I canβt understand if now.
Linq
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);