如何访问字典的键/值?我有这样的代码:
Try
If keystrokeDictionary.ContainsKey(letter) Then
keystrokeDictionary.Keys.Equals(letter)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return letterLetter是一个单独的字母,传入时只有它的字符串值。那么keystrokedictionary就是一个字典,它的信息是这样的:
{[65, 0]}
{[66, 1]}
{[67, 2]}其中键是第一个数字,值是第二个数字。因为我的代码没有正确查看键/值,所以它没有返回字母,因此无法工作。
发布于 2018-10-08 13:47:38
如下所示,使用item获取相应的值
letter = " ";
If keystrokeDictionary.ContainsKey(letter) Then
letter = keystrokeDictionary.Item(letter)
End If
Return letterhttps://stackoverflow.com/questions/17817538
复制相似问题