mardi 30 avril 2019

statements and return within a lambda expression lambda

In C# I'm trying to verify if a buss full of passengers is ready to go by verifying the passengers payments:

bool busReadyToGo = true;
passengers.Any(p => p.paymentStatus == PaymentRegistryEnum.NotPaid ?  busReadyToGo = false; return busReadyToGo; : continue; );

So this should check all the passengers payment status, if it encounters one passenger that hasn't paid then it stops right there and returns busReadytoGo = false. otherwise it continues iterating/filtering passengers, which means it will later return true if a passenger hasn't paid.

Not sure if this is the right way to do this within the Linq/lambda expression, because I keep getting syntax errors.

Aucun commentaire:

Enregistrer un commentaire