Having prob looping through an array of struct elements
Hi everyone,
I am trying to loop through an array of structure elements and based on a condition of equality I want to modify one of the elements of the struct.
Here is the code for it.
public struct CartItem
{
public int product_id;
public int[] product_option_id;
public int qty;
public int school_id;
}
public class Cart
{
CartItem[] cartItems;
public void AddItem(CartItem NewCartItem)
{
foreach (CartItem ci in cartItems)
{
if (ci.Equals(NewCartItem))
ci.qty = NewCartItem.qty;
}
}
}
The error I am getting is during compile. It complains on line //ci.qty = NewCartItem.qty; The compiler says "The left hand side on an assigment must be a variable, property or indexer.
Can someone please help me out here...
Thanks,
Mansoor.