0
This questioning came to my head in an activity I was doing here at work.
What would be the best way to do this operation?
The example I bring would be say we have a T object, and we have a List, if I operate for example:
objeto.Where(o => o.Data < DateTime.Now).ForEach(o => fazX());
We would have in this case logically 2 lists, but in code we have 1 only, if I wanted to operate the other part I would have to do another Where this way:
objeto.Where(o => o.Data > DateTime.Now).ForEach(o =>fazY());
That way the two parts of the list operate with different functions, but I wanted to know if there is a way to do all this only in 1 line, I believe it is possible since it seems to me a simple and common problem, I just could not find here or elsewhere.
Um, I didn’t think of that possibility, I thought I would have something more elegant with Linq or something like that, but I liked that solution too.
– David Ferrari