Mega Code Archive

 
Categories / VB.Net / Language Basics
 

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