本文整理汇总了VB.NET中System.Linq.Queryable.Average方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Queryable.Average方法的具体用法?VB.NET Queryable.Average怎么用?VB.NET Queryable.Average使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。
在下文中一共展示了Queryable.Average方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: List
Dim grades As New List(Of Integer)(New Integer() {78, 92, 100, 37, 81})
Dim average As Double = grades.AsQueryable().Average()
MsgBox(String.Format("The average grade is {0}.", average))
输出:
The average grade is 77.6.
示例2: longs
Dim longs() As Nullable(Of Long) = {Nothing, 10007L, 37L, 399846234235L}
Dim average As Nullable(Of Double) = longs.AsQueryable().Average()
MsgBox(String.Format("The average is {0}.", average))
输出:
The average is 133282081426.333.
示例3: fruits
Dim fruits() As String = {"apple", "banana", "mango", "orange", "passionfruit", "grape"}
' Determine the average string length in the array.
Dim average As Double = fruits.AsQueryable().Average(Function(s) s.Length)
MsgBox(String.Format("The average string length is {0}.", average))
输出:
The average string length is 6.5.