Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IndexOf with String array in VB.NET

How would I find the index of an item in the string array in the following code:

Dim arrayofitems() as String
Dim itemindex as UInteger
itemindex = arrayofitems.IndexOf("item test")
Dim itemname as String = arrayofitems(itemindex)

I'd like to know how I would find the index of an item in a string array. (All of the items are lowercase, so case shouldn't matter.)

like image 703
Eugene Avatar asked Sep 08 '10 17:09

Eugene


1 Answers

It's a static (Shared) method on the Array class that accepts the actual array as the first parameter, as:

Dim arrayofitems() As String
Dim itemindex As Int32 = Array.IndexOf(arrayofitems, "item test")
Dim itemname As String = arrayofitems(itemindex)

MSDN page

like image 153
Hans Olsson Avatar answered Oct 08 '22 09:10

Hans Olsson