Alex Rivera | Logout

Fastest way to find an item in a list?

Asked 2010-01-16T00:24:42.473
15

I have an unsorted list of strings. I can place these items in an array, List, SortedList, whatever.

I need to find the fastest way of looking up a string in this list. Am I better off dumping the list into an array, sorting it, then implementing binary search? Or does the framework provide a way to do this?

Thanks

P.S. Using VS2008 against .NET 2.0

Edit
Report

1 Answer

2

If you will only have to find one object, one time, just start at the beginning and look at each one until you find it. If you will have to repeat this Find operation multiple times against the same list, to find different items, then sort it keep the sorted list and do a binary search...

answered 2010-01-16T00:28:46.257

Your Answer