我有一个字符串列表.
我想在其中删除一个如下:
settings.RecentSearches.Keys.Remove(itemToAdd.Key); settings.RecentSearches.Keys.Add(itemToAdd.Key);
错误:
Mutating a key collection derived from a dictionary is not allowed.
我想在其中添加和删除值.
我能做什么?
您无法从字典的键集合中删除项目.您必须使用Dictionary.Remove从字典本身中删除该项.