Question: Attention all list / LINQ lovers, I have a small challenge for you.

I have two list:

```
List<ObjectInfo> firstListObject;
List<ObjectInfo> secondListObject;

```

The first list is a list that I use to manage data. The second list I use to add items as the process goes on. So, from times to times, I will add / remove items on my list.

I have these fields:

```
public int m_ObjectID { get;set; }
public bool m_IsSelected { get;set; }

```

And my intention is that each time I "update" my `secondListObject`, I need to scroll through all the `firstListObject` to set the `m_IsSelected` value to true. **ELSE** the value must be `false`, meaning that if an item lands in the list the first time, then is removed afterward, the item's `m_IsSelected` goes false.

Can anyone help me out? Thanks!

**EDIT**

Here's what I have done so far:

```
foreach (var singleOrDefault in secondListObject
    .Select(objectInfo => firstListObject
        .SingleOrDefault(_item => _item.m_ObjectID == inventoryInfo.m_ObjectID))
    .Where(singleOrDefault => singleOrDefault != null))
{
    singleOrDefault
        .m_IsSelected = true;
}

```

Well, in a way, this works. It sets the item I am looking for to true. By default, all `m_IsSelected` value are false.

But if I remove the item, the `m_IsSelected` remains true, and that's what I need to do.

So, in a sentence: I need to make a loop in the `firstListObject` and check if there's any "occurrence" (based on the ID) of each of item of the `secondListObject`. If that's true, I'll switch the `m_IsSelected` to true. I just need to make sure that else the `m_IsSelected` is false, which I do not know how to do...

Answer: 
If the issue is **performance** *as its a large array containing data back from 1930*, unless you are doing something like an autocomplete (which will require a re-search everytime the user types a char), **your biggest problem will be data-transfer** rather than client-side processing.

Either way, if it's a big bunch of data, **don't send to the client**. Implement a service that will do the calculation, retrieve and send the result back to you.

On server-side (or if you are really obsessive about implementing in client-side), if performance is poor while iterating through the array (or selecting the database?), your best bet is a [**Trie-like data structure**](http://en.wikipedia.org/wiki/Trie) (it is the most common way of implementing substring search for scenarios like auto-complete).
Basically, no.

But if you are concerned about iterating through the whole list, you can use a for loop which you break out of as soon as you find a match.