我有两个模型类:
public class SalesItem
{
public string ProductName { get; set; }
public double UnitPrice { get; set; }
public int Quantity { get; set; }
}
public class ProductItem : INotifyPropertyChanged
{
public string ProductName { get; set; }
public double UnitPrice { get; set; }
}
我有一个 SalesItem 列表List<ProductItem> products
,如何将其转换为List<SalesItem> sales
已编辑
List<ProductItem> salesList = new List<ProductItem>();
List<SalesItem> salesItem = salesList.Cast<SalesItem>();
错误:
Connot implicitly convert type 'System.Collections.Generic.IEnumerable<Model.SalesItem>' to 'System.Collections.Generic.List<Model.SalesItem>'. An explicit conversion exists (are you missing a cast?