I want to check if all items of a list meet a set of criteria. Currently I'm doing it as below:
bool AreValid(list<string> vals)
{
bool allValid=true;
foreach(string val in vals)
{
if(!condition1)
...
allValid=false;
else if(!condition2)
...
allValid=false;
}
return allValid;
}
The reason I can't use LINQ All() is that for each failed condition I'm doing some job.
Now I wonder it is safe to set allValid as true by default?