匹配字典值我有一个复合字典和一个列表C#LINQ只保留基于列表
Dictionary<Point, List<int>> GroupedIndex
int[] TobeMatched
现在我要检查每一个关键,是否还有TobeMatched阵列中的任何匹配值。如果匹配,则只保留该密钥的匹配值并删除其他值。如果没有匹配,则删除密钥。
Example:
GroupedIndex: [0] -> Key [X=1;Y=1]; Values [0] -> 5, [1] -> 10
[1] -> Key [X=1;Y=2]; Values [0] -> 1, [1] -> 3, [2] -> 6
TobeMatched: {1,2,6}
Result expected:
New dictionary: [0] -> Key[X=1;Y=2]; Values [0] -> 1, [1] -> 6
是否有可能在linq中实现这一点?
你卡在哪里? – V4Vendetta