LINQ为这个foreach

pap*_*zzo 0 .net c# linq

我怀疑有LINQ,但我无法弄清楚
selectedKeys是一个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");
    } 
}
Run Code Online (Sandbox Code Playgroud)

Ahm*_*IEM 6

你应该使用Select

return FTSWords7bit.Select(w=> 
                  new FTSword7bitThesaurus(this, w, 
                                           selectedKeys.Contains(w.Key)));
Run Code Online (Sandbox Code Playgroud)