我有问题Dictionary(buzzCompaignsPerUserIntersets)
。我有字典(key = stringand value = ICollection),我想从每个键的值中删除,这里验证条件的活动是我使用的代码:
buzzCompaignsPerUserIntersets = Dictionary<string, ICollection<Buzzcompaign> ;
foreach(var dic_compaign in buzzCompaignsPerUserIntersets)
{
var listCompaign = buzzCompaignsPerUserIntersets[dic_compaign.Key];
for (int i = 0; i < listCompaign.Count(); i++)
{
if (listCompaign.ElementAt(i).MayaMembership.MayaProfile.MayaProfileId == profile_id)
buzzCompaignsPerUserIntersets[dic_compaign.Key].Remove(listCompaign.ElementAt(i));
}
}
使用这段代码,我得到了一个奇怪的结果,因为我遍历了一个从中删除元素的字典。