59
1
Imports System
2
Imports System.Linq
3
Imports System.Collections.Generic
4
5
6
Public Module Module1
7
Public Sub Main()
8
Dim studentList = New List(Of Student) From {
9
New Student() With {.StudentID = 1, .StudentName = "John", .Age = 13 },
10
New Student() With {.StudentID = 2, .StudentName = "Moin", .Age = 21 },
11
New Student() With {.StudentID = 3, .StudentName = "Bill", .Age = 18 },
12
New Student() With {.StudentID = 4, .StudentName = "Ram", .Age = 20 },
13
New Student() With {.StudentID = 5, .StudentName = "Ron", .Age = 15 }
14
}
15
16
17
Dim avgAge = studentList.Average(Function(s) s.Age)
18
19
Console.WriteLine("Average Age of Student: {0}", avgAge)
20
21
22
End Sub
23
End Module
24
Cached Result
1
2
3
5
8
13
21
34
55
89
2
3
5
8
13
21
34
55
89