Bagikan melalui


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

Definisi

Melewati jumlah elemen tertentu secara berurutan lalu mengembalikan elemen yang tersisa.

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)

Jenis parameter

TSource

Jenis elemen source.

Parameter

source
IQueryable<TSource>

Untuk IQueryable<T> mengembalikan elemen dari.

count
Int32

Jumlah elemen yang akan dilewati sebelum mengembalikan elemen yang tersisa.

Mengembalikan

IQueryable<TSource>

Yang IQueryable<T> berisi elemen yang terjadi setelah indeks yang ditentukan dalam urutan input.

Atribut

Pengecualian

source adalah null.

Contoh

Contoh kode berikut menunjukkan cara menggunakan Skip<TSource>(IQueryable<TSource>, Int32) untuk melewati jumlah elemen tertentu dalam array yang diurutkan dan mengembalikan elemen yang tersisa.

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

Keterangan

Metode ini Skip<TSource>(IQueryable<TSource>, Int32) menghasilkan MethodCallExpression yang mewakili pemanggilan Skip<TSource>(IQueryable<TSource>, Int32) dirinya sebagai metode generik yang dibangun. Kemudian meneruskan MethodCallExpression ke CreateQuery(Expression) metode yang diwakili IQueryProvider oleh Provider properti source parameter.

Perilaku kueri yang terjadi sebagai akibat dari menjalankan pohon ekspresi yang mewakili panggilan Skip<TSource>(IQueryable<TSource>, Int32) tergantung pada implementasi jenis source parameter. Perilaku yang diharapkan adalah bahwa ia melompati elemen pertama count dan source mengembalikan elemen yang tersisa.

Berlaku untuk