我有一个问题...如果 containsvalue 的条件为真,我试图将其放入字符串字典键值列表中:
但是,这是不正确的:(
这是一个代码:
Private listID As New List(Of String) ' declaration of list
Private dictionaryID As New Dictionary(Of String, Integer) ' declaration of dictionary
'put a keys and values to dictionary
dictionaryID.Add("first", 1)
dictionaryID.Add("second", 2)
dictionaryID.Add("first1", 1)
If dictionaryID.ContainsValue(1) Then ' if value of dictinary is 1
Dim pair As KeyValuePair(Of String, Integer)
listID.Clear()
For Each pair In dictionaryID
listID.Add(pair.Key)
Next
End If
现在,列表必须有两个元素... -> "first" 和 "first1"
你能帮助我吗?非常感谢你!