Public Sub Add(ByVal phone As String, ByVal name As String)
MyBase.InnerHashtable.Add(phone, name)
End Sub
'--Subroutine to extract the value from a dictionary when the key is passed as input
Public Function Item(ByVal phone As String) As String
Return CStr(MyBase.InnerHashtable.Item(phone))
End Function
示例項:。的關鍵查字典(VB.NET
'--Adding key and values to the dictionary
myDict.Add("6812036998", "Horton")
myDict.Add("6812036999", "Olive")
我需要幫助,在字典中的反向查找鑑於key
我應該能夠找到名稱然而,我下面不會工作代碼,這是錯誤的
Public Function lookupValue(ByVal name As String)
Return CStr(MyBase.InnerHashtable.Item(name))
End Function
爲什麼你想找到'name' 結束在'Dictionary'中,當已經給出'name'時。或者我想你想在'key'的時候找到'name'? – jamiedanq