本文整理匯總了VB.NET中System.Linq.Queryable.Count方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Queryable.Count方法的具體用法?VB.NET Queryable.Count怎麽用?VB.NET Queryable.Count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。
在下文中一共展示了Queryable.Count方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: fruits
Dim fruits() As String = {"apple", "banana", "mango", _
"orange", "passionfruit", "grape"}
Dim numberOfFruits As Integer = fruits.AsQueryable().Count()
MsgBox(String.Format( _
"There are {0} items in the array.", _
numberOfFruits))
輸出:
There are 6 items in the array.
示例2: pets
Structure Pet
Public Name As String
Public Vaccinated As Boolean
End Structure
Shared Sub CountEx2()
' Create an array of Pet objects.
Dim pets() As Pet = {New Pet With {.Name = "Barley", .Vaccinated = True}, _
New Pet With {.Name = "Boots", .Vaccinated = False}, _
New Pet With {.Name = "Whiskers", .Vaccinated = False}}
' Count the number of unvaccinated pets in the array.
Dim numberUnvaccinated As Integer = pets.AsQueryable().Count(Function(p) p.Vaccinated = False)
MsgBox(String.Format("There are {0} unvaccinated animals.", numberUnvaccinated))
End Sub
輸出:
There are 2 unvaccinated animals.