0

我怀疑有 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");
    } 
}
4

2 回答 2

6

你应该使用选择

return FTSWords7bit.Select(w=> 
                  new FTSword7bitThesaurus(this, w, 
                                           selectedKeys.Contains(w.Key)));
于 2013-04-30T12:43:40.253 回答
2

它需要多长时间?

get 
{
    var result = FTSWords7bit
      .Select(x => new FTSword7bitThesaurus(this, x, selectedKeys.Contains(x.Key));
    Debug.Write("Done FTSthersarus FTSwordsPlusSelected");
    return result;
} 
于 2013-04-30T12:44:49.227 回答