开发者

Comparing two Dictionary of Dictionaries

开发者 https://www.devze.com 2023-01-17 01:38 出处:网络
I asked a similar question earlier in the week but I don\'t think my original description of the problem was very coherent, so I am trying again.

I asked a similar question earlier in the week but I don't think my original description of the problem was very coherent, so I am trying again.

I have the following Dictionaries:

public Dictionar开发者_开发技巧y<string, List<DateTime>> 1stDict = new Dictionary<string, List<DateTime>>();

Dictionary<string, Dictionary<DateTime, double>> 2ndDict= new Dictionary<string, Dictionary<DateTime, double>>();

I need to create a third Dictionary

Dictionary<string, Dictionary<DateTime, double>> 3rdDict= new Dictionary<string, Dictionary<DateTime, double>>();

Containing Dictionaries with values from 2ndDict where DateTime does not exist in 1stDict.

I've made some attempts using nested foreach statements but having no luck.

Any advice?

Thanks, Brian.


var thirdDict = secondDict.ToDictionary(
    x => x.Key, 
    x => x.Value.Keys.Except(firstDict[x.Key]).ToDictionary(y => y, y => x.Value[y]));
0

精彩评论

暂无评论...
验证码 换一张
取 消