我想在我的詞典中找到我的源列表的所有出現。在另一個列表中搜索整數列表C#
目前,我通過我的字典循環,並比較每個字典的值。
Dictionary<string, list<int>> refList.
List<int> sourceList.
foreach(KeyValuePair<string, List<int>> kvp in refDict)
{
List<int> refList = (List<int>)kvp.Value;
bool isMatch = (refList.Count == sourceList.Count && refList.SequenceEqual(sourceList));
if (isMatch)
{
......
......
}
}
我想找到索引以我的我的源列表的所有occurances的字典。
聽起來像一個集交集給我。也許你應該使用HashSets而不是列表? – mpen
我沒有看到問題。你的代碼看起來完整。 –
您的意思是字典<字符串,列表> refDict? –