C#把四个dictionary的内容复制到一个dictionary中,用什么方法?
1个回答
展开全部
var dictionaries = new List< Dictionary<TKey,
TValue> >(){ dict1, dict2, dict3, ... }.selectMany(dict =>
dict).toDictionary(pair => pair.key, pair => pair.value);
TValue> >(){ dict1, dict2, dict3, ... }.selectMany(dict =>
dict).toDictionary(pair => pair.key, pair => pair.value);
追问
能解释一下参数吗
追答
Dictionary<int, string> dic = new Dictionary<int, string>();
dic.Add(1, "aaa");
dic.Add(2, "bbb");
Dictionary<int, string> dic2 = new Dictionary<int, string>();
dic2.Add(3, "ccc");
dic2.Add(4, "ddd");
var dictionaries = new List< Dictionary<int,string> >(){ dic,dic2 }.SelectMany(dict =>dict).ToDictionary(pair => pair.Key, pair => pair.Value);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询