【发布时间】:2010-07-20 15:24:14
【问题描述】:
谁能告诉我为什么这不起作用?
public class GeocodeCoord
{
public string Outcode { get; set; }
public int X { get; set; }
public int Y { get; set; }
}
List<GeocodeCoord> _geocode;
using (MyDataContext db = new MyDataContext())
{
_geocode = db.Geocodes.Select(g => new GeocodeCoord { g.postcode, g.x, g.y }).ToList<GeocodeCoord>();
}
我收到以下错误:
无法使用集合初始化程序初始化类型“Search.GeocodeCoord”,因为它没有实现“System.Collections.IEnumerable”
【问题讨论】:
-
什么不起作用?你有例外吗?您是否收到编译时错误?
-
我得到一个编译器错误,刚刚添加了额外的信息......干杯
标签: linq linq-to-sql