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);
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>, содержащий элементы из входной последовательности, начиная с указанного индекса.

Исключения

source имеет значение null.

Примеры

В следующем примере кода показано, как использовать для 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) создает объект , MethodCallExpression представляющий вызов Skip<TSource>(IQueryable<TSource>, Int32) как сконструированный универсальный метод. Затем он передает в MethodCallExpressionCreateQuery(Expression) метод объекта , IQueryProvider представленный свойством Providersource параметра .

Поведение запроса, возникающее в результате выполнения дерева выражений, представляющего вызов Skip<TSource>(IQueryable<TSource>, Int32) , зависит от реализации типа source параметра. Ожидаемое поведение заключается в том, что он пропускает первые count элементы в source и возвращает остальные элементы.

Применяется к