2つのモデルクラスがあります。
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?