G
giant food
I need some input from someone who is more familiar with the .NET
framework classes.
I have a few programming problems where the user passes in a
comma-delimited string of integers (e.g. "2,7,6,23,5"), and I need to
search it repeatedly as I'm looping over a recordset.
My usual method of doing this is to use the Split() function to parse
the string into an array, and then do sequential searches for
particular IDs like this:
for i as integer = lbound(arr) to ubound(arr)
if arr(i) = searchInt then
'int found; do something
end if
next
Is there a better way? I've also tried [Array].BinarySearch, for when
my list is longer. I'd like to use some sort of list object that I
build given the comma-separated list, which I could verify was only a
list of integers (or some other type). Thanks
--Frank
framework classes.
I have a few programming problems where the user passes in a
comma-delimited string of integers (e.g. "2,7,6,23,5"), and I need to
search it repeatedly as I'm looping over a recordset.
My usual method of doing this is to use the Split() function to parse
the string into an array, and then do sequential searches for
particular IDs like this:
for i as integer = lbound(arr) to ubound(arr)
if arr(i) = searchInt then
'int found; do something
end if
next
Is there a better way? I've also tried [Array].BinarySearch, for when
my list is longer. I'd like to use some sort of list object that I
build given the comma-separated list, which I could verify was only a
list of integers (or some other type). Thanks
--Frank