Collection Classes in .net - the StringCollection
This is the ninth part of an article on collection classes in .net with C#. This part covers the StringCollection.
The StringCollection class can be found at System.Collections.Specialized.StringCollection
In essence this is just a strongly typed ArrayList. It works just like an ArrayList but holds only strings. We therefore get performance benefits since there is no casting. We also get compile time type checking and type safety - just like we do with generics. And in fact this begs the question as to whether this class is now obsolete since we now have generics? Any offers on this question - use the form below.
Of course even if this is obsolete, it does still need to be kept for legacy code - it's just a question of whether we use it for new code or not. I would say not.
See the comments at the end of http://msdn.microsoft.com/en-us/library/system.collections.specialized.stringcollection(VS.80).aspx
Ok not much else to say on StringCollection other than here is a simple code example.
For the first part see http://www.audacs.co.uk/ViewPage.aspx?PageID=512
For the next part on the SortedList see http://www.audacs.co.uk/ViewPage.aspx?PageID=522