有没有办法过滤掉使用该值的字典列表?
目前的实施是这样的:
List<Dictionary<string, object>> queue = new List<Dictionary<string, object>>();
//Some code here
queue = queue.Where(x => (string)x[DictionaryKey] != "some Value Here").ToList();
但是这似乎并没有根据传递的值返回过滤后的列表。
要过滤字典,请使用以下条件,x是一个字典,其中您只过滤没有指定值的对。
queue.Where(x => !x.ContainsValue("some Value Her"))
我想你正在寻找类似的东西:
queue = queue.Where(x => !x.ContainsValue("some value here")).ToList();
它将返回列表中没有“some value here”值的所有Dictionary对象。
你可以随时做到这一点
Foreach(Dictionary item in queue){
if(item.Keys.Contains("value")){
queue.Remove(item);
}
}
可能会奏效