次の方法で共有


Queryable.Skip<TSource>(IQueryable<TSource>, Int32) メソッド

定義

シーケンス内の指定された数の要素をバイパスし、残りの要素を返します。

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)

型パラメーター

TSource

sourceの要素の型。

パラメーター

source
IQueryable<TSource>

要素を返す IQueryable<T>

count
Int32

残りの要素を返す前にスキップする要素の数。

戻り値

IQueryable<TSource>

入力シーケンス内の指定したインデックスの後に出現する要素を含む IQueryable<T>

属性

例外

sourcenullです。

次のコード例では、 Skip<TSource>(IQueryable<TSource>, Int32) を使用して、並べ替えられた配列内の指定された数の要素をスキップし、残りの要素を返す方法を示します。

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

注釈

Skip<TSource>(IQueryable<TSource>, Int32) メソッドは、構築されたジェネリック メソッドとしての呼び出しSkip<TSource>(IQueryable<TSource>, Int32)自体を表すMethodCallExpressionを生成します。 次に、source パラメーターのProvider プロパティで表されるIQueryProviderCreateQuery(Expression) メソッドにMethodCallExpressionを渡します。

呼び出し Skip<TSource>(IQueryable<TSource>, Int32) を表す式ツリーを実行した結果として発生するクエリ動作は、 source パラメーターの型の実装によって異なります。 想定される動作は、source内の最初のcount要素をスキップし、残りの要素を返すということです。

適用対象