In a list, I have 12 records (hypothetical) and there is a field called ValorCampoFlag
, where this field receives 1 or null
, for example. If I do a validation on it and the result if there is at least one with a value of 1, should I use Any
or All
?
minhaVarBool = minhaLista.All(l => l.ValorCampoFlag == 1);
Or so:
minhaVarBool = minhaLista.Any(l => l.ValorCampoFlag == 1);
What strategy should I use for this type of result, ie set a Boolean variable.
The list brings me several records and it is enough to have one in that condition to set the variable.