VB.Net program to demonstrate the LINQ Average() function using LINQ query syntax

Hi everyone do you know about VB.Net program to demonstrate the LINQ Average() function using LINQ query syntax. With this article, you can clearly see everything you have in doubt.

VB.Net program to demonstrate the LINQ Average() function using LINQ query syntax

VB.Net program to demonstrate the LINQ Average() function using LINQ query syntax

'VB.NET program to demonstrate the LINQ Average() 
'function using LINQ query syntax.

Imports System
Imports System.IO
Imports System.Linq

Module Module1
    Public Class Employee
        Public id As Integer
        Public name As String
        Public age As Integer
        Public salary As Integer
    End Class

    Sub Main()
        Dim empList = New List(Of Employee) From
        {
            New Employee() With {.id = 101, .name = "Amit", .age = 21, .salary = 5000},
            New Employee() With {.id = 102, .name = "Arun", .age = 22, .salary = 7000},
            New Employee() With {.id = 103, .name = "Aman", .age = 23, .salary = 6000},
            New Employee() With {.id = 104, .name = "Amar", .age = 21, .salary = 6700},
            New Employee() With {.id = 105, .name = "Akki", .age = 22, .salary = 7500},
            New Employee() With {.id = 105, .name = "Anuj", .age = 23, .salary = 8700}
        }

        Dim avgSalary = Aggregate emp In empList Into Average(emp.salary)

        Console.WriteLine("Average Salary of Employee: {0}", avgSalary)
    End Sub
End Module
Average Salary of Employee: 6816.66666666667
Press any key to continue . . .

Final Words

Through this article, we have come to know clearly that VB.Net program to demonstrate the LINQ Average() function using LINQ query syntax. If you have any doubts please leave a comment via the comment box.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment