我怀疑有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");
}
}
答案 0 :(得分:6)
您应该使用Select
return FTSWords7bit.Select(w=>
new FTSword7bitThesaurus(this, w,
selectedKeys.Contains(w.Key)));
答案 1 :(得分:2)
linq需要怎么做?
get
{
var result = FTSWords7bit
.Select(x => new FTSword7bitThesaurus(this, x, selectedKeys.Contains(x.Key));
Debug.Write("Done FTSthersarus FTSwordsPlusSelected");
return result;
}