I have a list of objects like this:
List list = new List(); list.Add(new ClassName() { Name = 1, Amount = 5 }); list.Ad
Do it via LINQ:
var result = list.GroupBy(x => x.Name) .Select(x => new ClassName { Name = x.Key, Amount = x.Sum(i => i.Amount) }) .ToList();
Read more about LINQ here: http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b