测试类:
Public Class durp
Public somelist As New List(Of PointF)
Public Sub stuff()
somelist.Add(New PointF)
somelist(0).X = 5
End Sub
End Class
它在行上告诉我somelist(0).x = 5表示"表达式是一个值,因此不能成为作业的目标"
笏?
答案 0 :(得分:4)
如果你真的想使用List(),那么创建你自己的PointF版本,它是一个Class而不是Struct。
否则,创建一个局部变量,修改它,然后将其放回:
Public Sub stuff()
somelist.Add(New PointF)
Dim ptF As PointF = somelist(0)
ptF.X = 5
somelist(0) = ptF
End Sub
或者,构建列表然后将其转换为数组。然后,您可以像原先计划的那样直接使用它:
Public Class durp
Public somearray() As PointF
Public Sub stuff()
Dim somelist As New List(Of PointF)
somelist.Add(New PointF)
' ... add a bunch more points somehow ...
somearray = somelist.ToArray
End Sub
Public Sub stuff2()
somearray(0).X = 5
End Sub
End Class