IOrderedEnumerable<TElement> 接口

定义

表示已排序序列。Represents a sorted sequence.

generic <typename TElement>
public interface class IOrderedEnumerable : System::Collections::Generic::IEnumerable<TElement>
public interface IOrderedEnumerable<TElement> : System.Collections.Generic.IEnumerable<TElement>
type IOrderedEnumerable<'Element> = interface
    interface seq<'Element>
    interface IEnumerable
Public Interface IOrderedEnumerable(Of TElement)
Implements IEnumerable(Of TElement)

类型参数

TElement

序列中的元素的类型。The type of the elements of the sequence.

实现

示例

下面的示例演示如何对字符串数组执行主要和次要排序。The following example demonstrates how to perform a primary and secondary ordering on an array of strings. 它还表明生成IOrderedEnumerable<TElement>的是可枚举的。It also demonstrates that the resulting IOrderedEnumerable<TElement> is enumerable.

// Create an array of strings to sort.
string[] fruits = { "apricot", "orange", "banana", "mango", "apple", "grape", "strawberry" };

// Sort the strings first by their length and then alphabetically
// by passing the identity selector function.
IOrderedEnumerable<string> sortedFruits1 =
    fruits.OrderBy(fruit => fruit.Length).ThenBy(fruit => fruit);

// Output the resulting sequence of strings.
foreach (string fruit in sortedFruits1)
    Console.WriteLine(fruit);

// This code produces the following output:
//
// apple
// grape
// mango
// banana
// orange
// apricot
// strawberry

' Create an array of strings to sort.
Dim fruits() As String = _
    {"apricot", "orange", "banana", "mango", "apple", "grape", "strawberry"}

' Sort the strings first by their length and then alphabetically by passing the identity selector function.
Dim sortedFruits1 As IOrderedEnumerable(Of String) = _
    fruits.OrderBy(Function(ByVal fruit) fruit.Length).ThenBy(Function(ByVal fruit) fruit)

Dim output As New System.Text.StringBuilder
' Output the resulting sequence of strings.
For Each fruit As String In sortedFruits1
    output.AppendLine(fruit)
Next

' Display the results.
MsgBox(output.ToString())

' This code produces the following output:
'
' apple
' grape
' mango
' banana
' orange
' apricot
' strawberry

注解

此类型可枚举,因为它继承IEnumerable<T>自。This type is enumerable because it inherits from IEnumerable<T>.

扩展方法ThenBy和对ThenByDescending类型IOrderedEnumerable<TElement>的对象进行操作。The extension methods ThenBy and ThenByDescending operate on objects of type IOrderedEnumerable<TElement>. 类型IOrderedEnumerable<TElement>的对象可通过调用一个主要排序方法获取, OrderBy IOrderedEnumerable<TElement>OrderByDescending通过调用返回的。An object of type IOrderedEnumerable<TElement> can be obtained by calling one of the primary sort methods, OrderBy or OrderByDescending, which return an IOrderedEnumerable<TElement>. ThenBy而且ThenByDescending,从属排序方法也会返回类型IOrderedEnumerable<TElement>为的对象。ThenBy and ThenByDescending, the subordinate sort methods, in turn also return an object of type IOrderedEnumerable<TElement>. 此设计允许对ThenByThenByDescending执行任意数量的连续调用,其中每个调用对从上一个调用返回的已排序数据执行从属排序。This design allows for any number of consecutive calls to ThenBy or ThenByDescending, where each call performs a subordinate ordering on the sorted data returned from the previous call.

方法

CreateOrderedEnumerable<TKey>(Func<TElement,TKey>, IComparer<TKey>, Boolean)

根据某个键对 IOrderedEnumerable<TElement> 的元素执行后续排序。Performs a subsequent ordering on the elements of an IOrderedEnumerable<TElement> according to a key.

GetEnumerator()

返回循环访问集合的枚举数。Returns an enumerator that iterates through a collection.

(继承自 IEnumerable)

扩展方法

CopyToDataTable<T>(IEnumerable<T>)

在给定其泛型参数 TDataTable 的输入 DataRow 对象的情况下,返回包含 IEnumerable<T> 对象副本的 DataRowReturns a DataTable that contains copies of the DataRow objects, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

CopyToDataTable<T>(IEnumerable<T>, DataTable, LoadOption, FillErrorEventHandler)

在给定其泛型参数 TDataRow 的输入 DataTable 对象的情况下,将 IEnumerable<T> 对象复制到指定的 DataRowCopies DataRow objects to the specified DataTable, given an input IEnumerable<T> object where the generic parameter T is DataRow.

Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

Ancestors<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个节点的上级。Returns a collection of elements that contains the ancestors of every node in the source collection.

Ancestors<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个节点的上级。Returns a filtered collection of elements that contains the ancestors of every node in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

DescendantNodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子代节点的集合。Returns a collection of the descendant nodes of every document and element in the source collection.

Descendants<T>(IEnumerable<T>)

返回元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a collection of elements that contains the descendant elements of every element and document in the source collection.

Descendants<T>(IEnumerable<T>, XName)

返回经过筛选的元素集合,其中包含源集合中每个元素和文档的子代元素。Returns a filtered collection of elements that contains the descendant elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Elements<T>(IEnumerable<T>)

返回源集合中每个元素和文档的子元素的集合。Returns a collection of the child elements of every element and document in the source collection.

Elements<T>(IEnumerable<T>, XName)

返回源集合中经过筛选的每个元素和文档的子元素集合。Returns a filtered collection of the child elements of every element and document in the source collection. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

InDocumentOrder<T>(IEnumerable<T>)

返回节点集合(其中包含源集合中的所有节点),并按文档顺序排列。Returns a collection of nodes that contains all nodes in the source collection, sorted in document order.

Nodes<T>(IEnumerable<T>)

返回源集合中每个文档和元素的子节点集合。Returns a collection of the child nodes of every document and element in the source collection.

Remove<T>(IEnumerable<T>)

将源集合中的每个节点从其父节点中移除。Removes every node in the source collection from its parent node.

适用于