How to group multiple array of object in c#

Oct 17 2017 6:12 AM
Hi,
 
I am trying to group an array of objects and sum the result of each grouped value.
 
object[] products =
{ new object[] {"Soap", "1" ,10},
new object[] { "Soap", "2", 20 },
new object[] { "Soap1", "1",12 },
new object[] { "Soap", "3",30 },
new object[] { "Soap2", "2" ,10},
new object[] { "Soap1", "2" ,40} };
 
I need the output to be like 
 
Soap    1    10
Soap    2    20
Soap    3    30
-------------------
Total           50 
------------------- 
Soap1  1   12
Soap1   2   40
 -------------------  
Total            52
-------------------- 
Soap2   2   10 
 ------------------
Total            10
-------------------- 

Answers (2)