Hello,
I am in a dilemma, as I am not able to understand what is wrong n this piece of code.
int m = 0;
while(m < soitemfinalprice.Length)
{
Double soamt = 0;
foreach (var soitem in so)
{
foreach (var soitemprice in soitem.SODetails)
{
soamt = soamt + soitemprice.SO_Item_Final_Price;
}
soitemfinalprice[m] = soamt;
m++;
}
}
Here, soitemfinalprice is an array, say of size 3. "so" is a List of class objects, and each "so" contains another List of objects.
Suppose "so" contains 3 items, say 'A', 'B', 'C'.
'A' has two 'SODetails', which has SO_Item_Final_Price values 100 and 200.
'B' has one 'SODetails', which has SO_Item_Final_Price value 100.
'C' has three 'SODetails', which has SO_Item_Final_Price values 50, 100 and 200.
My requirement is that, I need to get the following values:
soitemfinalprice[1] = 300, soitemfinalprice[2] = 100, soitemfinalprice[3] = 350.
What happens now is, I am getting values as:
soitemfinalprice[1] = 750, soitemfinalprice[2] = 750, soitemfinalprice[3] = 750.
What is wrong in this Loop code ?