Mega Code Archive

 
Categories / VB.Net / Data Structure
 

Converts an array of one type to an array of another type

Imports System Imports System.Drawing Imports System.Collections.Generic Public Class Example     Public Shared Sub Main()         Dim apf() As PointF = { _             New PointF(27.8, 32.62), _             New PointF(1111.3, 1111.273), _             New PointF(7.5, 1111.2)  }         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))         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