小编Ang*_*ana的帖子

如何在 C# 中从字典中删除 KEY

我有一本名为d如上所述的字典。

Dictionary<string, int> d = new Dictionary<string, int>();
    d["dog"] = 1;
    d["cat"] = 5;
Run Code Online (Sandbox Code Playgroud)

现在,如果我想删除密钥,"cat"我无法使用该Remove()方法,因为它只删除关联的相应值,而不删除密钥本身。那么有没有办法删除密钥呢?

c# dictionary key

20
推荐指数
2
解决办法
3万
查看次数

标签 统计

c# ×1

dictionary ×1

key ×1