Mega Code Archive

 
Categories / VB.Net / Data Structure
 

List(T) ConvertAll(TOutput) Method converts List(Of T) to another type

Imports System Imports System.Drawing Imports System.Collections.Generic Public Class Example     Public Shared Sub Main()         Dim lpf As New List(Of PointF)         lpf.Add(New PointF(7.8, 2.2))         lpf.Add(New PointF(9.3, 7.3))         lpf.Add(New PointF(7.5, 2.2))         For Each p As PointF In lpf             Console.WriteLine(p)         Next         Dim lp As List(Of Point) = lpf.ConvertAll(New Converter(Of PointF, Point)(AddressOf PointFToPoint))         For Each p As Point In lp             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