This project is read-only.

Performance suggestion with StringCollection

Topics: Business Logic Layer
Mar 15, 2008 at 10:50 PM

A performance suggestion:
Replacing all the StringCollections that use at least one time the method 'Contains' with StringDictionary.
The both collections can be use for the same purpose, but StringCollections .Contains() is an O(n) operation and StringDictionary .Contains() is an O(1) operation.
Mar 16, 2008 at 9:51 PM
But one is a collection and the other a dictionary. A collection is not name/value like a dictionary. How would you suggest using a dictionary instead?
Mar 16, 2008 at 11:09 PM
StringDirectory accept null as value. So StringDirectory with keys and values null can act exactly as StringCollection but with much better
performance when searching.
Mar 16, 2008 at 11:14 PM
StringDictionary, not StringDirectory. of course. Sorry