Check for the occurence of a value in an array

rmatthew

Centurion
Joined
Dec 30, 2002
Messages
115
Location
Texas
I have an string array that I want to contain distinct values. What I need to do is search the array for a value and if it isn't there I need to go ahead and add it. Is there a way to do this without having to loop through the array and compare. Seems as if in 6 there was a function for doing this (at least I think I did it with an integer array at some point) :)

Thanks in advance.
 
If you add all your strings to an ArrayList class instead of a
conventional array, you can use the ArrayList's IndexOf method
to get the Index of a certain string. If it returns -1 then that item
wasn't found.

[edit]Actually I just realized this method IS in a conventional array,
and it works the same way.[/edit]
 
Back
Top