选择集合类Selecting a Collection Class

请务必仔细选择你的集合类。Be sure to choose your collection class carefully. 使用错误的类型可能会限制集合的使用。Using the wrong type can restrict your use of the collection.

重要

请避免使用 System.Collections 命名空间中的类型。Avoid using the types in the System.Collections namespace. 推荐使用泛型版本和并发版本的集合,因为它们的类型安全性很高,并且还经过了其他改进。The generic and concurrent versions of the collections are recommended because of their greater type safety and other improvements.

请考虑下列问题:Consider the following questions:

LINQ to Objects 与 PLINQLINQ to Objects and PLINQ

LINQ to Objects 让开发人员能够使用 LINQ 查询访问内存中对象,条件是该对象类型实现 IEnumerableIEnumerable<T>LINQ to Objects enables developers to use LINQ queries to access in-memory objects as long as the object type implements IEnumerable or IEnumerable<T>. LINQ 查询提供了一种通用的数据访问模式,与标准 foreach 循环相比,它通常更加简洁,可读性更高,并且可提供筛选、排序和分组功能。LINQ queries provide a common pattern for accessing data, are typically more concise and readable than standard foreach loops, and provide filtering, ordering, and grouping capabilities. 有关详细信息,请参阅 LINQ to Objects (C#)LINQ to Objects (Visual Basic)For more information, see LINQ to Objects (C#) and LINQ to Objects (Visual Basic).

PLINQ 提供 LINQ to Objects 的并行实现,在许多情况下,可通过更有效地利用多核计算机提供更快的查询执行。PLINQ provides a parallel implementation of LINQ to Objects that can offer faster query execution in many scenarios, through more efficient use of multi-core computers. 有关详细信息,请参阅并行 LINQ (PLINQ)For more information, see Parallel LINQ (PLINQ).

请参阅See also