📜  c# list keyvaluepair 更新值 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:13.754000             🧑  作者: Mango

代码示例1
var list = new List>();
list.Add(new KeyValuePair("Cat", 1));
list.Add(new KeyValuePair("Dog", 2));
list.Add(new KeyValuePair("Rabbit", 4));

int removalStatus = list.RemoveAll(x => x.Key == "Rabbit");

if (removalStatus == 1)
{
    list.Add(new KeyValuePair("Rabbit", 5));
}