开发者

How can I seek key of dictionary by index value?

开发者 https://www.devze.com 2023-01-30 23:25 出处:网络
How can 开发者_如何转开发I get the key of a dictionary by passing the index value? I\'m trying:

How can 开发者_如何转开发I get the key of a dictionary by passing the index value?

I'm trying:

If rs.Fields("NM").Value = dictNM.key(0)

that is, I want it to compare to the first key in the dictionary

but I get the error

Compile error: Invalid use of property

I tried googling, but to no avail. I'm hoping this is even possible.


You should be able to use the Keys property:

dictNM.Keys(0)

Edit:
One thing to keep in mind is that the order of the keys is unspecified, see MSDN


Dictionary.ElementAt(index) works for me. It returns the Key/Value pair at the specified index.

0

精彩评论

暂无评论...
验证码 换一张
取 消