Mega Code Archive

 
Categories / VB.Net / Language Basics
 

Declare a Func variable and assign a lambda expression to the variable

Imports System.Collections.Generic Imports System.Linq Module Func    Public Sub Main()       Dim selector As Func(Of String, String) = Function(str) str.ToUpper()       Dim words() As String = { "A", "B", "C", "D" }       Dim aWords As IEnumerable(Of String) = words.Select(selector)       For Each word As String In aWords          Console.WriteLine(word)       Next    End Sub End Module