[数组]如何从名称索引? [英] [Array] How Index from Name ?
问题描述
我有一个阵列。
我有一个元素的名字。
我需要相关索引。
是否有某种GetIndex方法
或者我必须使用For Next cicle
直到我遇到给定的名字?
I have an array.
I have the name of an element.
I need the related index.
Is there a sort of "GetIndex" method
or I have to use the For Next cicle
until I met the given name?
推荐答案
Tim,
你为一个数组做的索引。
VBB中的实例
for i as integer = 0 to myArray.Length - 1
''做你想做的事
next
C#
For(int i = 0; i< myArray.Lenght; i ++){//做你想做的事}
你知道那边有没有是特殊语言新闻组。
microsoft.public.dotnet.languages.vb或csharp或vs
我希望这有帮助,
>
Cor
" tim" < ti*@inwind.it> schreef in bericht
news:43 ************ @ news.tariffenet.it ...
Tim,
The index you make yourself for an array.
by instance in VBNet
for i as integer = 0 to myArray.Length - 1
''do what you want
next
C#
For (int i=0;i<myArray.Lenght;i++){//do what you want}
Did you know by the way that there are special language newsgroups.
microsoft.public.dotnet.languages.vb or csharp or vs
I hope this helps,
Cor
"tim" <ti*@inwind.it> schreef in bericht
news:43************@news.tariffenet.it...
我有一个阵列。 />
我有一个元素的名字。
我需要相关的索引。
是否有一种GetIndex方法
或者我必须使用For Next cicle
直到我遇到给定的名字?
I have an array.
I have the name of an element.
I need the related index.
Is there a sort of "GetIndex" method
or I have to use the For Next cicle
until I met the given name?
>有没有一种GetIndex?方法
Array.IndexOf(yourArray,yourName)
Mattias
-
Mattias Sj?gren [MVP] mattias @ mvps.org
http:/ /www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
请回复到新闻组。
>Is there a sort of "GetIndex" method
Array.IndexOf(yourArray, yourName)
Mattias
--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
tim< ti*@inwind.it>写道:
tim <ti*@inwind.it> wrote:
我有一个数组。
我有一个元素的名称。
I have an array.
I have the name of an element.
究竟做什么你的意思是名字元素?如果你的意思是用于填充数组的变量的名称,那就没有
对于元素所引用的对象本身的含义。 />
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet
如果回复群组,请不要邮寄我也是
What exactly do you mean by the "name" of the element? If you mean the
name of a variable which was used to populate the array, that has no
meaning to the object itself which is referred to by the element.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
这篇关于[数组]如何从名称索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!