匹配字典值我有一個複合字典和一個列表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