Best string container: StringCollection, Collection<string>, List<string>, ArrayList, ..?

和自甴很熟 提交于 2019-11-28 06:17:16

For what you need, List<string> is probably the most versatile. StringCollection was handy in 1.1, when (without generics) you needed specific classes for typed collections. Collection<string> is handy if you want to subclass it to provide validation etc.

Either way, in 3.5, LINQ will provide lots of additional methods for them - but without LINQ, List<T> has more features (Find, Sort, etc)

A List<T> would be the most efficient.

The Collection<T> class is just a wrapper for another type of list, the parameterless constructor initialises the Collection<T> with a List<T>.

An ArrayList is essentially the same as a List<object>, so you would have to cast the items to String when reading from it.

A StringCollection is just a type safe wrapper for an ArrayList.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!