Web developers use optional LINQ Skip While clause to bypass elements from the beginning of a query result until the supplied expression returns false. After expression returns false, the query returns all the remaining elements and the expression is ignored for the remaining result.
The Skip While clause can be used to exclude elements from a query only until the first time that the condition is not satisfied. The clause is most useful when Web developers are working with an ordered query result.
The Skip While clause has the following syntax:
Skip While expression
where expression is required and represents a condition to test elements for. The expression must return a Boolean value or a functional equivalent, such as an Integer to be evaluated as a Boolean.
The following code example uses the Skip While clause to bypass results until the first client from the UK is found:
Public Sub SkipWhileExample()
Dim products = GetProductList()
Dim productList = From prd In products _
Ordey By prd.County
Skip While IsInternationalProduct(prd)
For Each prd in productList
Console.WriteLine(prd.Company & vbTab & prd.Country)
Public Function IsInternationalProduct(ByVal prd as Product) as Boolean
If prd.Country = “UK” Then Return False