.net将(点的)列表转换为点F

.net将(点的)列表转换为点F,.net,vb.net,drawing,.net,Vb.net,Drawing,是否可以将点列表转换为点F 发件人: 致: 在c#中,它将是这样的 _Points.Select(p=>new PointF(p.X, p.Y)).ToList() 您可以在中使用Cast操作符。但是我也会使用一个列表(T): 如果您确实需要阵列: Dim pArray = pointFs.ToArray() 强大的CType,在两个完全不兼容的结构类型之间转换。强大,但这并不便宜,它需要反思@ArsenMkrt展示了一种廉价的方法。@HansPassant:但是有一个for点到点F@

是否可以将点列表转换为点F

发件人:

致:

在c#中,它将是这样的

_Points.Select(p=>new PointF(p.X, p.Y)).ToList()

您可以在中使用
Cast
操作符。但是我也会使用一个
列表(T)

如果您确实需要阵列:

Dim pArray = pointFs.ToArray()

强大的CType,在两个完全不兼容的结构类型之间转换。强大,但这并不便宜,它需要反思@ArsenMkrt展示了一种廉价的方法。@HansPassant:但是有一个for
点F
@HansPassant:btw,
DirectCast
不起作用(与
\u Points.ConvertAll(p=>(PointF)p)
中的C#
cast操作符
不同,因此我使用了
CType
_Points.Select(p=>new PointF(p.X, p.Y)).ToList()
Dim _Points As New List(Of Drawing.Point)
' fill the list 
Dim pointFs As List(Of Drawing.PointF) 
pointFs = _Points.ConvertAll(Function(p) CType(p, Drawing.PointF))
Dim pArray = pointFs.ToArray()