什么是之间的名单,其中的差别;串>和IEnumerable<字符串>?字符串、差别、名单、GT

2023-09-04 01:38:37 作者:烟只伤肺、不伤心

可能重复:   What's IEnumerable和阵列,IList的和列表之间的区别是什么?

什么是以上两者之间的区别是什么?

What's the difference between the above two?

推荐答案

A 名单,其中,串> 是一个具体的实施的IEnumerable&LT的;串> 。不同的是,的IEnumerable<字符串> 字符串名单,其中仅仅一个序列;字符串> 是可转位由 INT 的索引,可以添加和删除,并有特定的索引处插入项

A List<string> is a concrete implementation of IEnumerable<string>. The difference is that IEnumerable<string> is merely a sequence of string but a List<string> is indexable by an int index, can be added to and removed from and have items inserted at a particular index.

基本上,接口的IEnumerable&LT;字符串&GT; 让你流的字符串序列中,但列表与LT;字符串&GT; 可以让你做到这一点,以及修改和访问的具体方式列表中的项目。一个的IEnumerable&LT;字符串&GT; 字符串可重复,但不允许随机访问的一般顺序。 A 名单,其中,串&GT; 是一个特定的随机存取大小可变的集合

Basically, the interface IEnumerable<string> lets you stream the string in the sequence but List<string> lets you do this as well as modify and access the items in the lists in specific ways. An IEnumerable<string> is general sequence of string that can be iterated but doesn't allow random access. A List<string> is a specific random-access variable-size collection.