如何根据检查键值从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#中有以下代码,基本上是一个带有一些键及其值的简单字典.现在我想用新密钥更新这个字典中的现有密钥.可能吗?
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