Queryable.Skip<TSource>(IQueryable<TSource>, Int32) Método
Definición
Omite un número especificado de elementos en una secuencia y luego devuelve los elementos restantes.Bypasses a specified number of elements in a sequence and then returns the remaining elements.
public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
static System::Linq::IQueryable<TSource> ^ Skip(System::Linq::IQueryable<TSource> ^ source, int count);
public static System.Linq.IQueryable<TSource> Skip<TSource> (this System.Linq.IQueryable<TSource> source, int count);
static member Skip : System.Linq.IQueryable<'Source> * int -> System.Linq.IQueryable<'Source>
<Extension()>
Public Function Skip(Of TSource) (source As IQueryable(Of TSource), count As Integer) As IQueryable(Of TSource)
Parámetros de tipo
- TSource
Tipo de los elementos de source
.The type of the elements of source
.
Parámetros
- source
- IQueryable<TSource>
IQueryable<T> del que se van a devolver los elementos.An IQueryable<T> to return elements from.
- count
- Int32
Número de elementos que se van a omitir antes de devolver los elementos restantes.The number of elements to skip before returning the remaining elements.
Devoluciones
- IQueryable<TSource>
IQueryable<T> que contiene los elementos que hay después del índice especificado en la secuencia de entrada.An IQueryable<T> that contains elements that occur after the specified index in the input sequence.
Excepciones
source
es null
.source
is null
.
Ejemplos
En el ejemplo de código siguiente se muestra cómo usar Skip<TSource>(IQueryable<TSource>, Int32) para omitir un número especificado de elementos de una matriz ordenada y devolver los elementos restantes.The following code example demonstrates how to use Skip<TSource>(IQueryable<TSource>, Int32) to skip a specified number of elements in a sorted array and return the remaining elements.
int[] grades = { 59, 82, 70, 56, 92, 98, 85 };
// Sort the grades in descending order and
// get all except the first three.
IEnumerable<int> lowerGrades =
grades.AsQueryable().OrderByDescending(g => g).Skip(3);
Console.WriteLine("All grades except the top three are:");
foreach (int grade in lowerGrades)
Console.WriteLine(grade);
/*
This code produces the following output:
All grades except the top three are:
82
70
59
56
*/
Dim grades() As Integer = {59, 82, 70, 56, 92, 98, 85}
' Sort the grades in descending order and
' get all except the first three.
Dim lowerGrades = grades.AsQueryable() _
.OrderByDescending(Function(g) g) _
.Skip(3)
Dim output As New System.Text.StringBuilder
output.AppendLine("All grades except the top three are:")
For Each grade As Integer In lowerGrades
output.AppendLine(grade)
Next
' Display the output.
MsgBox(output.ToString())
' This code produces the following output:
' All grades except the top three are:
' 82
' 70
' 59
' 56
Comentarios
El Skip<TSource>(IQueryable<TSource>, Int32) método genera un MethodCallExpression que representa la llamada a Skip<TSource>(IQueryable<TSource>, Int32) sí mismo como un método genérico construido.The Skip<TSource>(IQueryable<TSource>, Int32) method generates a MethodCallExpression that represents calling Skip<TSource>(IQueryable<TSource>, Int32) itself as a constructed generic method. A continuación, pasa el MethodCallExpression al CreateQuery(Expression) método de IQueryProvider representado por la Provider propiedad del source
parámetro.It then passes the MethodCallExpression to the CreateQuery(Expression) method of the IQueryProvider represented by the Provider property of the source
parameter.
El comportamiento de la consulta que se produce como resultado de ejecutar un árbol de expresión que representa Skip<TSource>(IQueryable<TSource>, Int32) la llamada depende de la implementación del tipo del source
parámetro.The query behavior that occurs as a result of executing an expression tree that represents calling Skip<TSource>(IQueryable<TSource>, Int32) depends on the implementation of the type of the source
parameter. El comportamiento esperado es que omite los primeros count
elementos de source
y devuelve los elementos restantes.The expected behavior is that it skips the first count
elements in source
and returns the remaining elements.