获取Arraylist数据? [英] Getting Arraylist data?
问题描述
假设我有一个名为 MyArray 的 Arraylist ,其中包含3个计数。
在调试视图中,
MyArray | count = 3
[0] | 价值
[1] | 数= 12
[2] | 1
对于这种类型的arraylist这样就可以了:
ArrayList fromlist =(ArrayList)((ArrayList)MyArray)[2];
我会得到1.
但是在下面的Arraylist中我怎么能得到?
MyArray | count = 3
+ [0] < b> | something.ReturnObjectClass
+ [0] | something.ReturnObjectClass
+ [0] | something.Return ObjectClass
数据包含在内,如果你点击加号(+)就会找到。
我的问题是如何从Arraylist获取数据显示Return --- ObjectClass而不是数据。
谢谢。
Suppose I have an Arraylist called MyArray which contains 3 counts.
In Debug View,
MyArray|count=3
[0] | "value"
[1] | Count=12
[2] | 1
For this type of arraylist It is OK for like this:
ArrayList fromlist = (ArrayList)((ArrayList)MyArray)[2];
And I will get 1.
But in this following Arraylist how can I get?
MyArray|count=3
+ [0] | something.ReturnObjectClass
+ [0] | something.ReturnObjectClass
+ [0] | something.ReturnObjectClass
The data is contained and will find if you Click plus(+) .
My Question is how to get data from Arraylist which shows Return---ObjectClass instead of it data.
Thanks.
推荐答案
没有。 MyArray [2]是一个数字 - 1 - 不是ArrayList。 MyArray [1]似乎是一个arraylist ...
只是一个建议,但是你要返回或以其他方式传递多个值的ArrayList它可能最好创建特定的类来保存三个值并通过属性访问它们 - 然后你根本不需要抛出它们,并且不可能使用错误的元素!
No. MyArray[2] is a number - 1 - not an ArrayList. MyArray[1] would seem to be an arraylist...
Just a suggestion, but it you are returning or otherwise passing multiple values around with an ArrayList it would probably be a good idea to create specific class to hold the three values and access they via properties - then you don't have to cast them at all, and it is impossible to use the wrong element!
这篇关于获取Arraylist数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!