I got a list from a class like this:
List
FinalValsLinks = new
List();
and
the class contains:
public class
clsLinkObject
{
public string clientCode { get; set; }
public string clienteName { get; set; }
public string units { get;
set; }
}
It is filled through
the program with FinalValsEnlaces.Add(myLinkObj);
So it ends up with a list of
objects whose clientCode can be repeated. I need to group up the repeated ones and add
its units:
- select all the
clientCode that are repeated. - Add all those
units - Delete them and just add one with the total.
So, is there any easy
and straightforward way to do it, or just iterate through them and create a new
object?
In case the iteration way was the easier, would it be better to create
a new object or modify the one i
have?
foreach(var objadd in
FinalValsLinks)
{//count and add
string tmpclientN=
"";
tmpclientN = objadd.clientCode
...
}
thanks
in advance.
No comments:
Post a Comment