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.
Stephany Young - 25 Jan 2007 14:29 GMT
Dim FoundIt As Boolean = (myString.IndexOf(myInteger.ToString()) >= 0)
>I have a commaseparated string of integers (from My.Settings).
> I want to check if a specified number exists in the array.
[quoted text clipped - 6 lines]
> I don't have that many values so I prefer compact code before time
> optimization.
Jakob Lithner - 25 Jan 2007 14:57 GMT
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.
Jakob Lithner - 25 Jan 2007 14:31 GMT
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