patrick

patrick

  • NA
  • 397
  • 0

Combine all the data in a class

Jun 5 2012 5:17 PM
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)