gpt4 book ai didi

c# - IDictionary 如何在删除时获取已删除的项目值

转载 作者:太空狗 更新时间:2023-10-29 20:53:53 26 4
gpt4 key购买 nike

<分区>

我想知道是否可以通过键删除一个 IDictionary 项,并且同时得到它已被删除的实际值?

例子

类似于:

Dictionary<string,string> myDic = new Dictionary<string,string>();
myDic["key1"] = "value1";

string removed;
if (nameValues.Remove("key1", out removed)) //No overload for this...
{
Console.WriteLine($"We have just remove {removed}");
}

输出

//We have just remove value1

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com