如何引用arraylist中的第一个元素 [英] How to reference the first element in an arraylist
本文介绍了如何引用arraylist中的第一个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下内容来引用arraylist中的每个''元素'(这是
正确的术语): -
foreach(InternetExplorer即ar)
{
...
}
Q 。如何引用数组列表中的第n个元素?具体在
这个例子中我想引用arraylist ar的第一个元素。
我试过ar [1]但这并不能让我访问任何成员即...
TIA
加里
Hi I''m using the following to reference each ''element'' (is this the
correct term) in an arraylist: -
foreach (InternetExplorer ie in ar)
{
...
}
Q. How do I reference the nth element in an array list? Specifically in
this example I want to reference the first element of the arraylist ar.
I''ve tried ar[1] but this doesnt give me access to any members of ie.
TIA
Gary
推荐答案
第一个元素的索引为0.这有帮助吗?
Robin S.
-------------- ------------
< ga ******** @ myway.comwrote in message
news:11 ** *******************@16g2000cwy.googlegrou ps.com ...
The first element has an index of 0. Does that help?
Robin S.
--------------------------
<ga********@myway.comwrote in message
news:11*********************@16g2000cwy.googlegrou ps.com...
嗨我是使用以下内容在arraylist中引用每个''元素'(这是
正确的术语): -
foreach(InternetExplorer即ar中)
{
...
}
问:如何引用第n个元素在数组列表?具体在
这个例子中我想引用arraylist ar的第一个元素。
我试过ar [1]但是这并没有给我访问任何成员即。
TIA
Gary
Hi I''m using the following to reference each ''element'' (is this the
correct term) in an arraylist: -
foreach (InternetExplorer ie in ar)
{
...
}
Q. How do I reference the nth element in an array list? Specifically in
this example I want to reference the first element of the arraylist ar.
I''ve tried ar[1] but this doesnt give me access to any members of ie.
TIA
Gary
首先 - .Net中的大多数容器都是基于0的。第二,当你使用未打字的
容器时,你需要施放。
所以
InternetExplorer ie =( InternetExplorer)ar [0];
Marc
First - most containers in .Net are 0-based. Second, when using un-typed
containers you need to cast.
So
InternetExplorer ie = (InternetExplorer) ar[0];
Marc
铸造这是拼图中缺少的一块,谢谢你们两个! />
加里。
Marc Gravell写道:
casting that was the missing piece of the jigsaw, thankyou both!
Gary.
Marc Gravell wrote:
首先 - 大多数容器。净值为0。第二,当你使用未打字的
容器时,你需要施放。
所以
InternetExplorer ie =( InternetExplorer)ar [0];
Marc
First - most containers in .Net are 0-based. Second, when using un-typed
containers you need to cast.
So
InternetExplorer ie = (InternetExplorer) ar[0];
Marc
这篇关于如何引用arraylist中的第一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文