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

Comments

Popular posts from this blog

Shared / Static Class in vb.net/C#

Xamarin Forms : PopUp Page with RG.Plugins.Popup

Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)