我有两个类列表——“交付”和“取件”——我正在尝试制作第三个列表,将交付和取件添加在一起,即显示所有交付和取件而不是一个或另一个的列表。
在搜索了一下之后,我尝试了这个:
public List<String> listVisits()
{
List<String> listVisits = new List<string>();
listVisits.AddRange(listDeliveries);
listVisits.AddRange(listPickups);
}
但我只是收到错误说:
The best overloaded method match for 'System.Collections.Generic.List<string>.AddRange(System.Collections.Generic.IEnumerable<string>)' has found some invalid arguments
还有这个:
Argument 1: cannot convert from 'method group' to 'System.Collections.Generic.IEnumerable<string>'
这是什么意思,我该如何解决?
谢谢。
编辑:当前用户通过窗体输入数据。Deliveries 有两个 String 和一个 TimeSpan,Pickups 继承自 Deliveries,但还有两个 String。
public List<String> listDeliveries()
{
List<String> listDeliveries = new List<string>();
foreach (deliveries Deliv in delivery)
{
String DelivAsString = Deliv.DeliveryString();
listDeliveries.Add(DelivAsString);
}
return listDeliveries;
}
public List<String> listPickups()
{
List<String> listPickups = new List<string>();
foreach (pickups Pickup in pickup)
{
String PickupAsString = Pickup.PickupString();
listPickups.Add(PickupAsString);
}
return listPickups;
}