关于ILIST集合的迭代的当前索引? [英] CURRENT INDEX of Iteration on ILIST collection ?
问题描述
伙计们,
在某些收藏中使用FOR EACH
进行迭代时,是否有可能获得当前索引
(实现ILIST)不使用和外部计数变量(
以某种方式得到内部枚举器)?
For Each SomeObj As ArrayListObj中的对象
dim CurrentIndex as integer = ?????? (0,...,
ArrayListObj.count - 1)
Next SomeObj
-P
不幸的是,没有。我发现自己每天都想要这样一个机制几乎每天b $ b。
pa *********** @ libero.it 写道:
大家好,
当在某些集合上使用FOR EACH
进行迭代时,是否有可能得到当前索引
(实现ILIST)而不使用和外部计数变量( ,
以某种方式得到内部枚举器)?
For Each SomeObj As Object in ArrayListObj
暗淡的CurrentIndex为整数= ?????? (0,...,
ArrayListObj.count - 1)
Next SomeObj
-P
< pa *********** @ libero.itwrote in message
news:11 ********************** @ h48g2000cwc.googlegr oups.com ...
大家好,
在某些系列中使用FOR EACH
进行迭代时,是否有可能获得当前索引
(实现ILIST)而不使用和外部计数变量(
以某种方式获得内部计数器)?
for EachObj As Object in ArrayListObj
dim CurrentIndex as integer = ?????? (0,...,
ArrayListObj.count - 1)
Next SomeObj
我能想到的唯一方法,实际上是非常愚蠢的,将是:
For EachObj As Object in ArrayListObj
Dim CurrentIndex As Integer = ArrayListObj.IndexOf(SomeObj)
下一页
这是愚蠢的,因为拥有一个
$ b $会更有效率b递增变量。我首选的解决方案是始终编写像
这样的循环,我需要索引:
我的整数= 0到ArrayListObj.Count - 1
Dim SomeObj As Object = ArrayListObj(i)
下一页
我不确定这种语言是如何解决的
这样做的特殊构造,例如CountWith i声明......我们将把它留给组中的
语言理论家;)
For EachObj As Object in ArrayListObj CountWith i
下一页
Robinson ha scritto:
< blockquote class =post_quotes>
>
我能想到的唯一方法就是:
对于ArrayListObj中的每个SomeObj As对象
Dim CurrentIndex As Integer = ArrayListObj.IndexOf(SomeObj)
下一页
它是愚蠢的,因为拥有一个
递增变量会更有效率。我首选的解决方案是始终编码像
这样的循环,我需要索引:
>
For i As Integer = 0 To ArrayListObj.Count - 1
Dim SomeObj As Object = ArrayListObj(i)
下一个
我同意:))
>
我不确定这种语言是如何使用特殊构造来实现的,例如CountWith i声明......我们将把它留给组中的
语言理论家;)
For EachObj As Object in ArrayListObj CountWith i
下一个
这看起来真是个好主意。你在哪里得到它的?
我希望微软设计师做笔记:)
-P
ps 。
也许还有:
For EachObj As Object in ArrayListObj UseIndex I as integer
Next SomeObj
或
For EachObj As Object in ArrayListObj UseIndex I as integer
StartingFrom 0
Next SomeObj
:))Pamela
Hi guys,
Is it possible to get the current index, when iterating with FOR EACH
on some collection
(implementing ILIST) without using and external counting variable (,
that
is somehow getting the internal enumerator) ?
For Each SomeObj As Object In ArrayListObj
dim CurrentIndex as integer = ?????? (0,...,
ArrayListObj.count - 1 )
Next SomeObj
-P
Unfortunately, no. I find myself wanting such a mechanism an almost
daily basis.
pa***********@libero.it wrote:Hi guys,
Is it possible to get the current index, when iterating with FOR EACH
on some collection
(implementing ILIST) without using and external counting variable (,
that
is somehow getting the internal enumerator) ?
For Each SomeObj As Object In ArrayListObj
dim CurrentIndex as integer = ?????? (0,...,
ArrayListObj.count - 1 )
Next SomeObj
-P
<pa***********@libero.itwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...Hi guys,
Is it possible to get the current index, when iterating with FOR EACH
on some collection
(implementing ILIST) without using and external counting variable (,
that
is somehow getting the internal enumerator) ?
For Each SomeObj As Object In ArrayListObj
dim CurrentIndex as integer = ?????? (0,...,
ArrayListObj.count - 1 )
Next SomeObj
The only way I can think of, that is actually quite idiotic, would be:
For Each SomeObj As Object In ArrayListObj
Dim CurrentIndex As Integer = ArrayListObj.IndexOf ( SomeObj )
Next
It''s idiotic because it would be so much more efficient to have an
incrementing variable. My preferred solution is to always code loops like
this where I need to index:
For i As Integer = 0 To ArrayListObj.Count - 1
Dim SomeObj As Object = ArrayListObj ( i )
Next
I''m not sure how the language would work out with a special construct for
doing this, such as a "CountWith i" statement...We will leave it up to the
language theorists in the group ;)
For Each SomeObj As Object In ArrayListObj CountWith i
Next
Robinson ha scritto:
>
The only way I can think of, that is actually quite idiotic, would be:
For Each SomeObj As Object In ArrayListObj
Dim CurrentIndex As Integer = ArrayListObj.IndexOf ( SomeObj )
Next
It''s idiotic because it would be so much more efficient to have an
incrementing variable. My preferred solution is to always code loops like
this where I need to index:
>
For i As Integer = 0 To ArrayListObj.Count - 1
Dim SomeObj As Object = ArrayListObj ( i )
Next
I agree :))
>
I''m not sure how the language would work out with a special construct for
doing this, such as a "CountWith i" statement...We will leave it up to the
language theorists in the group ;)
For Each SomeObj As Object In ArrayListObj CountWith i
Next
This seems a really beautiful idea. Where did you get it ?
I hope Microsoft designer are taking notes :)
-P
ps.
perhaps also:
For Each SomeObj As Object In ArrayListObj UseIndex I as integer
Next SomeObj
or
For Each SomeObj As Object In ArrayListObj UseIndex I as integer
StartingFrom 0
Next SomeObj
:)) Pamela
这篇关于关于ILIST集合的迭代的当前索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!