最好的字符串容器:StringCollection,收集和LT;字符串>中名单,其中,字符串>中ArrayList中,..?
什么是最合适的容器只是用于保持与pdetermined上边界非$ P $,一些字符串数组其中长度是未知上它的创建
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.
对于简单的code这样的:
For simple code like:
var list = new SomeContainer(); // size is unknown
for()/foreach()/do()/while() // any loop
{
list.Add(string);
}
难道 StringCollection
作为字符串优化收集,或只是收藏<字符串>
或列表<字符串>
或的ArrayList
?它们之间有什么不同?
Is it StringCollection
as optimized Collection for string, or just Collection<string>
or List<string>
or ArrayList
? What is the different between them?
有关你所需要的,名单,其中,串&GT;
可能是最通用的。 StringCollection
是得心应手1.1,当(没有泛型),你需要特定的类的类型集合。 收藏&LT;字符串&GT;如果你要继承它提供验证等
是很方便的。
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.
无论哪种方式,在3.5,LINQ将提供大量额外的方法为他们 - 但没有LINQ,名单,其中,T&GT;
具有更多的功能(查找
,排序
等)
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)