How to check if all the elements of a list satisfy the same condition using a lambda expression?

1

I have a class that represents an entity in the database. This class runs a procedure that returns its data. I created a list of type and this list is loaded. Let's say this is the loaded list: vlstMinhaEntidade . How do I go through this list with lambda ?

Personal, for and foreach , this I know. The question would be with lambda . That did not work that way. The goal of this is just learning.

var teste = l in vlstMinhaEntidade...

The above gives error at all.

So you're giving it a go:

vbolErroDocTorObrigatorio = vlstDados.ForEach(
   l => l.IcObrigatorio == 0 && string.IsNullOrEmpty(l.DsPathDocumento)
);
    
asked by anonymous 11.02.2015 / 17:16

1 answer

1

I did that and solved it with All:

vbolErroDocTorObrigatorio = vlstDados.All(l => l.IcObrigatorio == 0 && String.IsNullOrEmpty(l.DsPathDocume

I got the answer in the SO in English.

    
11.02.2015 / 18:15