Converter(TInput, TOutput) Delegate represents a method that converts an object from one type to another type. : Lambda « Language Basics « VB.Net






Converter(TInput, TOutput) Delegate represents a method that converts an object from one type to another type.

 

Imports System
Imports System.Drawing
Imports System.Collections.Generic

Public Class Example

    Public Shared Sub Main()

        Dim apf() As PointF = {New PointF(2.8, 3.62),New PointF(7.5, 1.2)  }

        Console.WriteLine()
        For Each p As PointF In apf
            Console.WriteLine(p)
        Next

        Dim ap() As Point = Array.ConvertAll(apf,New Converter(Of PointF, Point)(AddressOf PointFToPoint))

        Console.WriteLine()
        For Each p As Point In ap
            Console.WriteLine(p)
        Next

    End Sub

    Public Shared Function PointFToPoint(ByVal pf As PointF) As Point
        Return New Point(CInt(pf.X), CInt(pf.Y))
    End Function
End Class

   
  








Related examples in the same category

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