Instantiate delegate to reference method : Lambda « Language Basics « VB.Net

Instantiate delegate to reference method


Module GenericFunc
   Public Sub Main()

      Dim convertMethod As Func(Of String, String) = AddressOf UppercaseString
      Dim name As String = "test"
   End Sub

   Private Function UppercaseString(inputString As String) As String
      Return inputString.ToUpper()
   End Function
End Module


Related examples in the same category

1.Func(T, TResult) represents a method that has one parameter and returns one value
2.Lambda Expression and Function
3.Declare a Func variable and assign a lambda expression to the variable
4.Predicate(T) Delegate represents the method that defines a set of criteria
5.Converter(TInput, TOutput) Delegate represents a method that converts an object from one type to another type.
6.Func(TResult) Delegate represents a method with no parameters returning a value of the type specified by the TResult parameter.