Question: I have a huge IEnumerable(suppose the name is myItems), which way is more effective?

Solution 1: Filter it first then ForEach.

```
Array.ForEach(myItems.Where(FILTER-IT-HERE).ToArray(),MY-ACTION);

```

Solution 2: Do RETURN in MY-ACTION if the item is not up to the mustard.

```
Array.ForEach(myItems.ToArray(),MY-ACTION-WITH-FILTER);

```

Is one of them always better than another? Or any other good suggestions? Thanks in advance.

Answer: 
Sometimes one has to create benchmark's because similar looking activities could produce radically different and unexpected results.

You do not say what your data source is so I'm going to assume it may be data on an SQL server in which case filtering at the server side will likely always be the best approach because you have minimized the amount of data transfer. Memory access is always faster than data transfer from disk to memory so whenever you can transfer fewer records, you are likely to have better performance.
If performance is a concern, it's unclear to me why you'd be bothering to construct an entire array in the first place. Why not just this?

```
foreach (var item in myItems.Where(FILTER-IT-HERE))
    MY-ACTION;

```

Or:

```
foreach (var item in myItems)
    MY-ACTION-WITH-FILTER;

```

I ask because, while the others are right that you can't really know without testing, I wouldn't expect there to be much difference between the above two options. I **would** expect there to be a difference, on the other hand, between creating/populating an array (seemingly for no reason) and *not* creating an array.