小编Dev*_*evi的帖子

选择KeyValuePair列表的值

如何根据检查键值从keyvaluepair列表中选择值

List<KeyValuePair<int, List<Properties>> myList = new List<KeyValuePair<int, List<Properties>>();
Run Code Online (Sandbox Code Playgroud)

在这里,我想得到

list myList[2].Value when myLisy[2].Key=5.
Run Code Online (Sandbox Code Playgroud)

我怎样才能实现这一目标?

c#

22
推荐指数
2
解决办法
7万
查看次数

如何在c#中动态更改字典中的键?

我在c#中有以下代码,基本上是一个带有一些键及其值的简单字典.现在我想用新密钥更新这个字典中的现有密钥.可能吗?

Dictionary<string, int> dictionary = new Dictionary<string, int>();
dictionary.Add("00", 2);
dictionary.Add("01", 1);
dictionary.Add("02", 0);
dictionary.Add("03", -1);
Run Code Online (Sandbox Code Playgroud)

在某些情况下,我使用键01删除了值.

现在我必须更新已删除密钥下方的密钥,如下所示.

dictionary.Add("00", 2);   
dictionary.Add("01", 0);
dictionary.Add("02", -1);
Run Code Online (Sandbox Code Playgroud)

可能吗?

c#

-2
推荐指数
1
解决办法
1186
查看次数

标签 统计

c# ×2