2
Answers

Combine all the data in a class

patrick

patrick

12y
1.2k
1
Hi everyone!  If I had a class, ReportInfo

class

ReportInfo
{

public String Name { get; set; }

public Double Data { get; set; }


}

How can I make a List<ReportInfo> combine so that all the names that match add their data?  for instance, if i had a List<reportinfo>  that had 

Name="Sales", Data=100;
Name="Sales", Data=100;
Name="Sales Tax", Data=100;
Name="Sales", Data=100;
Name="Sales Tax", Data=100;
Name="Sales", Data=100;

How can I get a single list<reportinfo>  that would contain

Name="Sales", Data=400;
Name="Sales Tax", Data=200;

Answers (2)