Lambda Expression for Search in Object
Lambda Expression for Search in Object
Code for Same is below
Public Class Form27
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim student As NStudent = New NStudent() With {.StudentID = 1, .StudentName = "John", .Age = 13}
Dim isStudentTeenAger = Function(s) s.Age > 12 And s.Age < 20
Console.WriteLine(isStudentTeenAger(student))
End Sub
End Class
Public Class NStudent
Private _studentID As Integer
Private _studentName As String
Private _age As Integer
Property StudentID() As Integer
Get
Return _studentID
End Get
Set(ByVal Value As Integer)
_studentID = Value
End Set
End Property
Property StudentName() As String
Get
Return _studentName
End Get
Set(ByVal Value As String)
_studentName = Value
End Set
End Property
Property Age() As Integer
Get
Return _age
End Get
Set(ByVal Value As Integer)
_age = Value
End Set
End Property
End Class
Code for Same is below
Public Class Form27
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim student As NStudent = New NStudent() With {.StudentID = 1, .StudentName = "John", .Age = 13}
Dim isStudentTeenAger = Function(s) s.Age > 12 And s.Age < 20
Console.WriteLine(isStudentTeenAger(student))
End Sub
End Class
Public Class NStudent
Private _studentID As Integer
Private _studentName As String
Private _age As Integer
Property StudentID() As Integer
Get
Return _studentID
End Get
Set(ByVal Value As Integer)
_studentID = Value
End Set
End Property
Property StudentName() As String
Get
Return _studentName
End Get
Set(ByVal Value As String)
_studentName = Value
End Set
End Property
Property Age() As Integer
Get
Return _age
End Get
Set(ByVal Value As Integer)
_age = Value
End Set
End Property
End Class
Comments
Post a Comment