Queryable.Skip<TSource>(IQueryable<TSource>, Int32) Metodo

Definizione

Ignora un numero specificato di elementi in una sequenza e quindi restituisce gli elementi rimanenti.

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)

Parametri di tipo

TSource

Tipo degli elementi di source.

Parametri

source
IQueryable<TSource>

Oggetto IQueryable<T> dal quale restituire elementi.

count
Int32

Il numero di elementi da ignorare prima di restituire gli elementi rimanenti.

Restituisce

IQueryable<TSource>

Un oggetto IQueryable<T> che contiene elementi presenti dopo l'indice specificato nella sequenza di input.

Eccezioni

source è null.

Esempio

Nell'esempio di codice seguente viene illustrato come usare Skip<TSource>(IQueryable<TSource>, Int32) per ignorare un numero specificato di elementi in una matrice ordinata e restituire gli elementi rimanenti.

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

Commenti

Il Skip<TSource>(IQueryable<TSource>, Int32) metodo genera un MethodCallExpression oggetto che rappresenta Skip<TSource>(IQueryable<TSource>, Int32) se stesso come metodo generico costruito. Passa quindi l'oggetto MethodCallExpression al CreateQuery(Expression) metodo dell'oggetto IQueryProvider rappresentato dalla Provider proprietà del source parametro .

Il comportamento della query che si verifica come risultato dell'esecuzione di un albero delle espressioni che rappresenta la chiamata Skip<TSource>(IQueryable<TSource>, Int32) dipende dall'implementazione del tipo del source parametro. Il comportamento previsto è che ignora i primi count elementi in source e restituisce gli elementi rimanenti.

Si applica a