Elegant lookup?

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.
 
G

Guest

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top