C# LINQ Query
position.CoordinateList = FenceItem.FencePosts.AsEnumerable().Select(coord => new FenceCoordinate
{
PosLat = coord.PLatitude,
PosLong = coord.PLongitude
}).ToList();
VB 查询
Dim position As New FencePosition()
position.CoordinateList = FenceItem.FencePosts.AsEnumerable().Select(Function(coord) New FenceCoordinate() With { _
.PosLat = coord.PLatitude, _
.PosLong = coord.PLongitude _
}).ToList()
但在 VB 中它给出了以下错误,
Value of type 'System.Collections.Generic.List(Of NMI.GeoFenceData.GeoDecision.FenceCoordinate)' cannot be converted to '1-dimensional array of NMI.GeoFenceData.GeoDecision.FenceCoordinate'.
我知道
这很旧,但无法抗拒。这是我头顶上的等效 VB.NET 代码:
position.CoordinateList = FenceItem.FencePosts
.AsEnumerable()
.Select(Function(coord) New FenceCoordinate With
{
.PosLat = coord.PLatitude,
.PosLong = coord.PLongitude
})
.ToList()