Queryable.Skip<TSource>(IQueryable<TSource>, Int32) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Contourne un nombre spécifié d’éléments dans une séquence, puis retourne les éléments restants.
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)
Paramètres de type
- TSource
Type des éléments de source.
Paramètres
- source
- IQueryable<TSource>
À IQueryable<T> partir duquel renvoyer des éléments.
- count
- Int32
Nombre d’éléments à ignorer avant de retourner les éléments restants.
Retours
Qui IQueryable<T> contient des éléments qui se produisent après l’index spécifié dans la séquence d’entrée.
- Attributs
Exceptions
source a la valeur null.
Exemples
L’exemple de code suivant montre comment utiliser Skip<TSource>(IQueryable<TSource>, Int32) pour ignorer un nombre spécifié d’éléments dans un tableau trié et retourner les éléments restants.
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
Remarques
La Skip<TSource>(IQueryable<TSource>, Int32) méthode génère un qui représente l’appel MethodCallExpressionSkip<TSource>(IQueryable<TSource>, Int32) lui-même en tant que méthode générique construite. Il passe ensuite la MethodCallExpressionCreateQuery(Expression) méthode de l’objet IQueryProvider représenté par la Provider propriété du source paramètre.
Le comportement de requête qui se produit suite à l’exécution d’une arborescence d’expressions qui représente l’appel Skip<TSource>(IQueryable<TSource>, Int32) dépend de l’implémentation du type du source paramètre. Le comportement attendu est qu’il ignore les premiers count éléments et source retourne les éléments restants.