VB.Net program to select specified fields using Any() LINQ extension method
'VB.NET program to demonstrate the
'LINQ Any() extension method.
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
End Class
Sub Main()
Dim empList = New List(Of Employee) From
{
New Employee() With {.id = 101, .name = "Amit", .age = 21},
New Employee() With {.id = 102, .name = "Arun", .age = 22},
New Employee() With {.id = 103, .name = "Aman", .age = 23},
New Employee() With {.id = 104, .name = "Amar", .age = 21},
New Employee() With {.id = 105, .name = "Akki", .age = 22},
New Employee() With {.id = 105, .name = "Anuj", .age = 23}
}
Dim result As Boolean = empList.Any(Function(e) e.age > 22)
If (result = True) Then
Console.WriteLine("There are few employees whose age is greater than 22")
Else
Console.WriteLine("There is no any employee whose age is greater than 22")
End If
End Sub
End Module
There are few employees whose age is greater than 22
Press any key to continue . . .
Table of Contents