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

后端 未结 2 1039
春和景丽
春和景丽 2020-12-08 09:58

What is the most suitable container just for strings holding in some array with non-predetermined upper boundary, which length is unknown on it\'s creation.

For simp

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 10:31

    For what you need, List is probably the most versatile. StringCollection was handy in 1.1, when (without generics) you needed specific classes for typed collections. Collection 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 has more features (Find, Sort, etc)

提交回复
热议问题