Click here to Skip to main content
15,905,028 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have a list containg
list<cls> Objlist = new list<cls>();

Obj1.Name="earth";
obj1.code="1"
Obj1.Value = 10;
objlist.add(Obj1);

Obj2.Name="sun";
obj1.code="2"
Obj2.value = 15;
objlist.add(Obj2);

Obj3.Name = "earth";
obj1.code="1"
Obj3.Value = 25;
objlist.add(Obj3);

Obj4.Name = "earth";
obj1.code="1"
Obj4.Value = 35;
objlist.add(Obj4);

Obj5.Name="sun";
obj1.code="2"
Obj5.value = 50;
objlist.add(Obj5);

Now i want to find a sub list using linq which contain,ie sum field contain sum of value group by id.
Obj1.Name="earth";
obj1.code="1"
Obj1.sum= 70;
and
Obj5.Name="sun";
obj1.code="2"
Obj5.sum= 65;
tks in advance
Posted

1 solution

See this[^] example for a similar use case.

/ravi
 
Share this answer
 
Comments
rajin kp 4-Dec-12 1:45am    
tks Ravi Bhavnani1
sunandandutt 4-Dec-12 1:57am    
Good One. My 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900