Sdílet prostřednictvím


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

Definice

Obchází zadaný počet prvků v sekvenci a vrátí zbývající prvky.

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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
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>
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Enumerating collections as IQueryable can require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
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)

Parametry typu

TSource

Typ prvků .source

Parametry

source
IQueryable<TSource>

Návrat IQueryable<T> prvků.

count
Int32

Počet prvků, které se mají přeskočit před vrácením zbývajících prvků.

Návraty

IQueryable<TSource>

Obsahuje IQueryable<T> prvky, které se vyskytují po zadaném indexu ve vstupní sekvenci.

Atributy

Výjimky

source je null.

Příklady

Následující příklad kódu ukazuje, jak lze přeskočit Skip<TSource>(IQueryable<TSource>, Int32) zadaný počet prvků v seřazené matici a vrátit zbývající prvky.

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

Poznámky

Metoda Skip<TSource>(IQueryable<TSource>, Int32) vygeneruje MethodCallExpression , která představuje samotné volání Skip<TSource>(IQueryable<TSource>, Int32) jako vytvořenou obecnou metodu. Pak předá MethodCallExpression metodu IQueryProviderCreateQuery(Expression) reprezentované Provider vlastností parametrusource.

Chování dotazu, ke kterému dochází v důsledku spuštění stromu výrazu, který představuje volání Skip<TSource>(IQueryable<TSource>, Int32) , závisí na implementaci typu parametru source . Očekávané chování spočívá v tom, že přeskočí první count prvky a source vrátí zbývající prvky.

Platí pro