Tutorial for Enumerable .Select

Issue #61 closed
KD created an issue

Hi

I can't get .Select to work, even though looking at the code online it seems there is a Select function.

I have a IDictionary<string, T> I'm doing a

IDictionary<string, T>.Where( ... predicate...)

, which returns a list of <string,T>.

So far so good. However I want to return a list of T, so I wanted to chain the above snippet with .Select() but it seems this is not possible.

I've tried doing a .Select on a IEnumerable directly but in vain.

I'm not sure if this is the appropriate channel to ask for a sample code for Select.

Comments (2)

  1. Stefan Glienke repo owner

    Hi,

    some methods are not part of IEnumerable because interface methods cannot have generic type parameters.

    You can do it like this:

    TCollections.Select<TPair<string,T>,T>Select(dict.Where(...))
    

    or if the predicate does not need the key for its evaluation:

    dict.Values.Where(...)
    

    For further questions please refer to https://groups.google.com/forum/#!forum/spring4d

  2. KD reporter

    I did not know that all the fun was happening on GG. I was searching on SO. Thanks for your support.

  3. Log in to comment