I have two model class:
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; }
}
I have a list of SalesItem, List<ProductItem> products, how can I cast it to List<SalesItem> sales
EDITED
List<ProductItem> salesList = new List<ProductItem>();
List<SalesItem> salesItem = salesList.Cast<SalesItem>();
Error:
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?
Tried and tested
Include namespace
and then
See it working
Casting will work if ProductItem is inherited from SalesItem class