Collection subset

Have can I return a subset of collection by using one class memeber as the filter criteria


Answer this question

Collection subset

  • Mark John

    I'm in love with the new generic List(Of T). Here is a little console application that illustrates one way to implement a search. It is very easy to extend this example to cover any criteria you would like for your search. I hope it gives you some ideas.

  • amit_toney

    Thanks Ray. I'll try out your solution later. However, I've got one more additional problem after retrieved the subset of the collection.

    For example, I've a set called Set A. Now, I've selected a subset called Subset A using your method and then I insert a new item into Subset A. What's the order of this new item in the Set A



  • cyberbob

    Ok. That's why I'm not going to do in this way as it makes the code seems too complicated. Moreover, I'm using BingList (Of T) instead of List (Of T). I found that the BindingList (Of T) doesn't provide the FindAll method.

  • Nissim L

    You're welcome! Unfortunately (for your interests), setA.FindAll() returns a new List. Or in other words, adding an element to subsetA will not alter setA.


    If you want to add an element to setA based on something in subsetA you could do something like this:
    setA.Insert(setA.IndexOf(elementOfSubsetA), New Name(firstName, lastName))
    This would add a new Name to setA one position closer to 0 than the element of interest. I hope that makes sense.


  • Collection subset