.NET - 我想这样做:Dim D as new Dictionary(of String, Array(OF MYOBJECT))
我想创建一个由字符串索引的字典: Dictionary(of String, ...)
我希望逗号后面的类型是 MyObject 的数组。
如果我所做的只是以下内容:
Dim D as new Dictionary(of String, Array)
我觉得每次访问成员时我都错过了一些性能:
Dim Object1 as MyObject = MyDictionary("Key1")(4)
它是否必须执行某种类型的查找来找出数组每次保存的对象类型我以这种方式访问它?
I'd like to create a Dictionary that is indexed by Strings: Dictionary(of String, ...)
I'd like the Type after the comma to be an Array of MyObject's.
If all I do is the following:
Dim D as new Dictionary(of String, Array)
I feel like I'm missing out on some performance very time I access a member:
Dim Object1 as MyObject = MyDictionary("Key1")(4)
Doesn't it have to perform some type of lookup to figure out what type of object the array is holding every time I access it in this manner?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果 Value 确实需要是 MyObject 的数组,您可以执行以下操作:
If the Value really needs to be an array of MyObject, you could do the following:
Array
不是你想要的;相反,使用您想要的强类型数组:这就像一个魅力。
Array
isn’t what you want; rather, use the strongly typed array that you want to have:This works like a charm.
使用数组,您在检索它时将调用类型转换。这个怎么样:
Using array, you will be invoking type casting when you retrieve it. How about this: