Get Index from String Array [C#]

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
Given an array [public string[] OptArr;] filled with Strings
I need a method that would allow me to give the string and have the function return the INDEX in the Array where that string is stored.

Any clues?
 
OptArr does not have a .IndexOf property.

Currently I am using the usual For/If loops but this reduces performance when my arrays become large.
 
My bad - VB makes me lazy like that. try the System.Array class' IndexOf method :
C#:
string[] OptArr = {"one","two","three"};
int i;
i= System.Array.IndexOf(OptArr,"two");
 
Back
Top