更新哈希表中的值 [英] Updating values in a hashtable

查看:89
本文介绍了更新哈希表中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everyone,



是否可以更新哈希表中的项目?



我想要如果需要更改任何值,能够更新某些项目,但是我尝试了更新值的不同方法,但是旧值的值或者它产生了后期绑定分配错误,以及Microsoft的帮助页面错误不是很有帮助: http://msdn.microsoft.com/en -us / library / dwkwy23c(v = vs.90).aspx [ ^ ]





这是一个例子我正在努力实现:



Hello Everyone,

Is it possible to update items in a hashtable?

I want to be able to update some items if any values need to be changed, however I have tried different ways of updating the values but either the values where the old values or it produced a Late-bound assignment error, and the Microsoft help page for that error is not very helpful: http://msdn.microsoft.com/en-us/library/dwkwy23c(v=vs.90).aspx[^]


Here is an example of what I am trying to achieve:

dim i as integer = 0

hashtable.item(i).description = Description.Text




i是一个整数,对应于哈希表中的键。



希望这是有道理的,请问有什么人帮我吗?



i is an integer which corresponds to the key in the hash-table.

Hope this makes sense, can anybody help me please?

推荐答案

哈希表不知道你在编译时会把它放进去。您可以使用字典并指定要放入其中的类型。否则你需要将你的散列表所保存的任何索引转换为正确的类型。



The hashtable has no idea what you will put into it at time of compilation. You could use a dictionary and specify the type you are going to put into it. Otherwise you need to cast whatever your hashtable holds at some index to the right type.

Dim hashtableas Dictionary(Of Integer, SomeClass);





祝你好运!



Good luck!


我最终决定从哈希中删除旧记录-table并重新输入新/更新记录的值。



不是解决问题的方法(更新哈希表中的值)但结果相同。
I decided in the end to just delete the old record from the hash-table and re-enter the values for the new/updated record.

Not really the solution to the problem (updating values in a hashtable) but it has the same outcome.


这篇关于更新哈希表中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆