paparazzo
paparazzo

Reputation: 45106

LINQ for this foreach

I suspect there is LINQ for this but I cannot figure it out
selectedKeys is a HashSet

public IEnumerable<FTSword7bitThesaurus> FTSwordsPlusSelected 
{ 
    get 
    {
        foreach (FTSword7bit w in FTSWords7bit)
        {
            yield return new FTSword7bitThesaurus(this, w, selectedKeys.Contains(w.Key));
        }
        Debug.Write("Done FTSthersarus FTSwordsPlusSelected");
    } 
}

Upvotes: 0

Views: 124

Answers (2)

Stefan Steinegger
Stefan Steinegger

Reputation: 64658

How linq does it need to be?

get 
{
    var result = FTSWords7bit
      .Select(x => new FTSword7bitThesaurus(this, x, selectedKeys.Contains(x.Key));
    Debug.Write("Done FTSthersarus FTSwordsPlusSelected");
    return result;
} 

Upvotes: 2

Ahmed KRAIEM
Ahmed KRAIEM

Reputation: 10427

You should use Select

return FTSWords7bit.Select(w=> 
                  new FTSword7bitThesaurus(this, w, 
                                           selectedKeys.Contains(w.Key)));

Upvotes: 6

Related Questions