IQueryable的,ICollection的,IList的与放大器之间的差异; IDictionary的接口 [英] Difference between IQueryable, ICollection, IList & IDictionary interface

查看:188
本文介绍了IQueryable的,ICollection的,IList的与放大器之间的差异; IDictionary的接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解的IQueryable,ICollection的,IList的与放大器之间的差异; IDictionary的接口 这是比较快的像迭代,索引,查询等。

I am trying to understand difference between IQueryable, ICollection, IList & IDictionary interface which is more faster for basic operations like iterating, Indexing, Querying and more.

哪个阶级喜欢收藏,列表,字典等将是很好的与这些接口启动时,我们应该使用这些类。使用这些类对他人的基本优势。

which class like Collection, List, Dictionary etc would be good to initiating with these interfaces and when should we be using these class. Basic advantages of using these classes over others.

我想读其他职位有类似的问题,但没有回答我的问题完全。 感谢您的帮助。

I tried reading other posts with similar questions but nothing answered my full questions. Thanks for the help.

推荐答案

所有这些接口的继承的IEnumerable ,你应该确保你明白。该接口基本上可以让你在一个的foreach 语句中使用的类(在C#)。

All of these interfaces inherit from IEnumerable, which you should make sure you understand. That interface basically lets you use the class in a foreach statement (in C#).

  • 的ICollection 是最基本的,你列出的接口。这是一个支持计数可枚举接口,并仅此而已。
  • 的IList 是一切ICollection的是,但它也支持添加和删除项目,通过索引检索项目等,这是最常用的接口对象列表,这是模糊我知道了。
  • 的IQueryable 是用于支持LINQ的枚举接口。您可以随时从一个IList创建一个IQueryable和使用LINQ到对象,但你还可以找到的IQueryable用于到实体SQL语句中的LINQ to SQL和LINQ的延迟执行。
  • 的IDictionary 是不同的动物,在某种意义上说,它是唯一的关键值的映射。它也可枚举的,你可以枚举键/值对,但除此之外,它服务于不同的目的,你所列出的其他人。
  • ICollection is the most basic of the interfaces you listed. It's an enumerable interface that supports a Count and that's about it.
  • IList is everything that ICollection is, but it also supports adding and removing items, retrieving items by index, etc. It's the most commonly-used interface for "lists of objects", which is vague I know.
  • IQueryable is an enumerable interface that supports LINQ. You can always create an IQueryable from an IList and use LINQ to Objects, but you also find IQueryable used for deferred execution of SQL statements in LINQ to SQL and LINQ to Entities.
  • IDictionary is a different animal in the sense that it is a mapping of unique keys to values. It is also enumerable in that you can enumerate the key/value pairs, but otherwise it serves a different purpose than the others you listed.

MSDN文档每一项都是不错的,所以我会在丰富你的理解从那里开始。

The MSDN documentation for each of these is decent, so I would start there in rounding out your understanding.

这篇关于IQueryable的,ICollection的,IList的与放大器之间的差异; IDictionary的接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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