Elegant lookup?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a commaseparated string of integers (from My.Settings).
I want to check if a specified number exists in the array.
My idea was to first convert to a string array and then do some kind of
search.
I can of course add them all manually to a hashtable, but is there some kind
of direct conversion that might help?

I don't have that many values so I prefer compact code before time
optimization.
 
I was just looking for methods on array and hashtable objects.
Generic List object had a convenient method that made it!

Dim ProfileArray() As String =
My.Settings.DefaultProfiles.Split(",;".ToCharArray)
Dim Profiles As New List(Of String)

Profiles.AddRange(ProfileArray)
......
If Profiles.Contains(dr.ProfileID.ToString)) Then
 
Will not work.
In this string "1,2,45,781,856" integer value 78 will be found but it should
not.

See my previous reply for a working solution.
Seems like you often refresh your brain just by telling someone else ... :-)

Thanks anyhow for your suggestion.
 
Back
Top