我试图将数据表转换为列表并重新运行为列表,但抛出异常
错误 1 可访问性不一致:返回类型"System.Collections.Generic.List
"比方法"Sample.Features.getData()"更难访问
.
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static List<Order> getData()
{
DataTable ds = getDataSource();
List<Order> listdata = new List<Order>();
for (int i = 0; i < ds.Rows.Count; i++)
{
Order ord = new Order();
ord.CustomerID = (int)ds.Rows[i]["CustomerID"];
listdata.Add(ord);
}
return listdata;
}
请告诉我,我做错了什么。
将Order
设为公共类。
Order 类的可访问性不如该方法。您应该检查订单是否不是私有/内部