Hi everyone,
I have a C# WPF window that I insert 4 List<T> a string,decimal,decimal, and int. Each list is numbered correctly 0,1,2… with the correct information in order in the list.
I am trying to create a public property of a List<myobject> that has properties myobject.string, myobject.decimal, myobject.decimal, myobject.int
How can I enter these properties into my list of my object? Here is what I have and some ways I have been trying.
public partial class ShoppingCart : Window
{
private List<string> listProductNames = new List<string>();
private List<decimal> listProductPrices = new List<decimal>();
private List<decimal> listProductSalesTax = new List<decimal>();
private List<int> listProductQuantity = new List<int>();
public List<Product> Cart => new List<Product>();
public ShoppingCart(Customer c, List<string> lpn, List<decimal> lpp, List<decimal> lpt, List<int> lpq)
{
InitializeComponent();
customer = c;
listProductNames = lpn;
listProductPrices = lpp;
listProductSalesTax = lpt;
listProductQuantity = lpq;
CreateCart(listProductNames, listProductPrices, listProductSalesTax, listProductQuantity);
PopulateListViewCart();
}
private void CreateCart(List<string> lpn, List<decimal> lpp, List<decimal> lpt, List<int> lpq)
{
selectedProduct = new Product();
foreach(string name in lpn)
{
selectedProduct.ProductName = name;
}
foreach(decimal price in lpp)
{
selectedProduct.ProductPrice = price;
}
foreach(decimal tax in lpt)
{
selectedProduct.ProductTax = tax;
}
foreach(int quantity in lpq)
{
selectedProduct.ProductQuantity = quantity;
}
Cart.Add(selectedProduct);
}
}