Using Func to do filter : Func « LINQ « VB.Net






Using Func to do filter

  



Module Program
    Sub Main()
        Dim currentVideoGames As String() = {"A", "B", "this is a test", "C", "D", "E"}

        Dim searchFilter As New Func(Of String, Boolean)(AddressOf Filter)
        Dim itemToProcess As New Func(Of String, String)(AddressOf ProcessItem)

        Dim subset = currentVideoGames.Where(searchFilter).OrderBy(itemToProcess).Select(itemToProcess)
        For Each game In subset
            Console.WriteLine("Item: {0}", game)
        Next

    End Sub

    Function Filter(ByVal str As String) As Boolean
        Return str.Length > 6
    End Function
    Function ProcessItem(ByVal str As String) As String
        Return str
    End Function

End Module

   
    
  








Related examples in the same category

1.Using Func to do filter 2
2.Func with user-defined function