什么是之间的名单,其中的差别;串>和IEnumerable<字符串>? [英] What's the difference between List<string> and IEnumerable<String>?

查看:124
本文介绍了什么是之间的名单,其中的差别;串>和IEnumerable<字符串>?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  <一href="http://stackoverflow.com/questions/764748/whats-the-difference-between-ienumerable-and-array-ilist-and-list">What's IEnumerable和阵列,IList的和列表之间的区别是什么?

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

What's the difference between the above two?

推荐答案

A 名单,其中,串&GT; 是一个具体的实施的IEnumerable&LT的;串&GT; 。不同的是,的IEnumerable&LT;字符串&GT; 字符串名单,其中仅仅一个序列;字符串&GT; 是可转位由 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.

这篇关于什么是之间的名单,其中的差别;串&GT;和IEnumerable&LT;字符串&GT;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆