"Dino Buljubasic" <di**@noplacelikehome.com> wrote in message news:qe********************************@4ax.com...
I am using lots of string comparisons using
String.StartsWith(subString) method
: : Is there a way to do this faster?
You can add all of the subStrings you want to compare against into a SortedList.
Then take the string you're testing and go one-character at a time.
When it starts with 'T', that immediately eliminates most of the subStrings you are
comparing against, narrowing you down to just those strings in the SortedList that
begin with 'T'. When the second character is 'o', that eliminates every string that
starts out like "The" or "Those" or "Tactfully."
Inevitably, you are only checking each character in your string no more than one
time, and you whittle down the number of subStrings you're comparing against
very quickly so there isn't that many comparisons going on.
Derek Harmon