2
C#では、SortedDictionaryであるサブセットを生成するLINQを使用してSortedDictionaryをフィルタする方法を教えてください。例えば。私は私が見つけた唯一の方法はSortedDictionaryのサブセットをSortedDictionaryとして取得する
SortedDictionary<TKey, TValue> SubDictionary<TKey, TValue> IEnumerable<KeyValuePair<TKey, TValue>> l)
{
SortedDictionary<TKey, TValue> result = new SortedDictionary<TKey, TValue>();
foreach (var e in l)
result[e.Key] = e.Value;
return result;
}
...
SortedDictionary<int, Person> source = ..fetch..
SortedDictionary<int, Person> filtered = SubDictionary(source.Where(x=>x.foo == bar))