gpt4 book ai didi

c# - 从值为空列表的字典中删除项目

转载 作者:太空狗 更新时间:2023-10-29 18:01:32 25 4
gpt4 key购买 nike

从值为空列表的字典中删除项目的最佳方法是什么?

IDictionary<int,Ilist<T>> 

最佳答案

var foo = dictionary
.Where(f => f.Value.Count > 0)
.ToDictionary(x => x.Key, x => x.Value);

这将创建一个字典。如果您想就地删除,Jon 的回答可以解决问题。

关于c# - 从值为空列表的字典中删除项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16340818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com