Queryable.SkipWhile メソッド

定義

指定された条件が満たされる限り、シーケンスの要素をバイパスした後、残りの要素を返します。

オーバーロード

SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>)

指定された条件が満たされる限り、シーケンスの要素をバイパスした後、残りの要素を返します。

SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Int32,Boolean>>)

指定された条件が満たされる限り、シーケンスの要素をバイパスした後、残りの要素を返します。 要素のインデックスは、述語関数のロジックで使用されます。

SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>)

ソース:
Queryable.cs
ソース:
Queryable.cs
ソース:
Queryable.cs

指定された条件が満たされる限り、シーケンスの要素をバイパスした後、残りの要素を返します。

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IQueryable<TSource> ^ SkipWhile(System::Linq::IQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, bool> ^> ^ predicate);
public static System.Linq.IQueryable<TSource> SkipWhile<TSource> (this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,bool>> predicate);
static member SkipWhile : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, bool>> -> System.Linq.IQueryable<'Source>
<Extension()>
Public Function SkipWhile(Of TSource) (source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Boolean))) As IQueryable(Of TSource)

型パラメーター

TSource

source の要素の型。

パラメーター

source
IQueryable<TSource>

返される要素が含まれる IQueryable<T>

predicate
Expression<Func<TSource,Boolean>>

各要素が条件を満たしているかどうかをテストする関数。

戻り値

IQueryable<TSource>

source で指定されたテストに合格しない連続する最初の要素から predicate の要素を含む IQueryable<T>

例外

source または predicatenull です。

次のコード例では、条件が true である限り、 を使用 SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>) して配列の要素をスキップする方法を示します。

int[] grades = { 59, 82, 70, 56, 92, 98, 85 };

// Get all grades less than 80 by first
// sorting the grades in descending order and then
// taking all the grades after the first grade
// that is less than 80.
IEnumerable<int> lowerGrades =
    grades.AsQueryable()
    .OrderByDescending(grade => grade)
    .SkipWhile(grade => grade >= 80);

Console.WriteLine("All grades below 80:");
foreach (int grade in lowerGrades)
    Console.WriteLine(grade);

/*
    This code produces the following output:

    All grades below 80:
    70
    59
    56
*/
Dim grades() As Integer = {59, 82, 70, 56, 92, 98, 85}

' Get all grades less than 80 by first  sorting the grades 
' in descending order and then taking all the grades that 
' occur after the first grade that is less than 80.
Dim lowerGrades = grades.AsQueryable() _
    .OrderByDescending(Function(grade) grade) _
    .SkipWhile(Function(grade) grade >= 80)

Dim output As New System.Text.StringBuilder
output.AppendLine("All grades below 80:")
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 below 80:
' 70
' 59
' 56

注釈

このメソッドには、型引数が型 Expression<TDelegate> の 1 つである型のパラメーターが少なくとも 1 つ Func<T,TResult> 含まれています。 これらのパラメーターでは、ラムダ式を渡すことができます。これは に Expression<TDelegate>コンパイルされます。

メソッドは SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>)MethodCallExpression 構築されたジェネリック メソッドとして自身を呼び出すことを SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>) 表す を生成します。 次に、 パラメーターの MethodCallExpressionCreateQuery(Expression) プロパティで表される の IQueryProvider メソッドに をProvidersource渡します。

呼び出し SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Boolean>>) を表す式ツリーを実行した結果として発生するクエリ動作は、 パラメーターの型の source 実装によって異なります。 予期される動作は、false を返す要素が見つかるまで、 のsource各要素にpredicate適用predicateされます。 その要素と残りのすべての要素が返されます。

適用対象

SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Int32,Boolean>>)

ソース:
Queryable.cs
ソース:
Queryable.cs
ソース:
Queryable.cs

指定された条件が満たされる限り、シーケンスの要素をバイパスした後、残りの要素を返します。 要素のインデックスは、述語関数のロジックで使用されます。

public:
generic <typename TSource>
[System::Runtime::CompilerServices::Extension]
 static System::Linq::IQueryable<TSource> ^ SkipWhile(System::Linq::IQueryable<TSource> ^ source, System::Linq::Expressions::Expression<Func<TSource, int, bool> ^> ^ predicate);
public static System.Linq.IQueryable<TSource> SkipWhile<TSource> (this System.Linq.IQueryable<TSource> source, System.Linq.Expressions.Expression<Func<TSource,int,bool>> predicate);
static member SkipWhile : System.Linq.IQueryable<'Source> * System.Linq.Expressions.Expression<Func<'Source, int, bool>> -> System.Linq.IQueryable<'Source>
<Extension()>
Public Function SkipWhile(Of TSource) (source As IQueryable(Of TSource), predicate As Expression(Of Func(Of TSource, Integer, Boolean))) As IQueryable(Of TSource)

型パラメーター

TSource

source の要素の型。

パラメーター

source
IQueryable<TSource>

返される要素が含まれる IQueryable<T>

predicate
Expression<Func<TSource,Int32,Boolean>>

各要素が条件に当てはまるかどうかをテストする関数。この関数の 2 つ目のパラメーターは、ソース要素のインデックスを表します。

戻り値

IQueryable<TSource>

source で指定されたテストに合格しない連続する最初の要素から predicate の要素を含む IQueryable<T>

例外

source または predicatenull です。

次のコード例では、要素のインデックスに依存する条件が true である限り、 を使用 SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Int32,Boolean>>) して配列の要素をスキップする方法を示します。

int[] amounts = { 5000, 2500, 9000, 8000,
                    6500, 4000, 1500, 5500 };

// Skip over amounts in the array until the first amount
// that is less than or equal to the product of its
// index in the array and 1000. Take the remaining items.
IEnumerable<int> query =
    amounts.AsQueryable()
    .SkipWhile((amount, index) => amount > index * 1000);

foreach (int amount in query)
    Console.WriteLine(amount);

/*
    This code produces the following output:

    4000
    1500
    5500
*/
Dim amounts() As Integer = {5000, 2500, 9000, 8000, _
                    6500, 4000, 1500, 5500}

' Skip over amounts in the array until the first amount
' that is less than or equal to the product of its
' index in the array and 1000. Take the remaining items.
Dim query = amounts.AsQueryable() _
    .SkipWhile(Function(amount, index) amount > index * 1000)

Dim output As New System.Text.StringBuilder
For Each amount As Integer In query
    output.AppendLine(amount)
Next

' Display the output.
MsgBox(output.ToString())

' This code produces the following output:

' 4000
' 1500
' 5500

注釈

このメソッドには、型引数が型 Expression<TDelegate> の 1 つである型のパラメーターが少なくとも 1 つ Func<T,TResult> 含まれています。 これらのパラメーターでは、ラムダ式を渡すことができます。これは に Expression<TDelegate>コンパイルされます。

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

呼び出し SkipWhile<TSource>(IQueryable<TSource>, Expression<Func<TSource,Int32,Boolean>>) を表す式ツリーを実行した結果として発生するクエリ動作は、 パラメーターの型の source 実装によって異なります。 予期される動作は、false を返す要素が見つかるまで、 のsource各要素にpredicate適用predicateされます。 その要素と残りのすべての要素が返されます。 各ソース要素のインデックスは、 の 2 番目の引数 predicateとして提供されます。

適用対象