title: Comparing specific properties of a generic list and merging similar data
body: <p>This is all in C#, using .NET 3.5.</p>
  
  <p>I have a list populated with book information. Each item contains the course abbreviation, the course number, and the section of the course:</p>
  
  <pre><code>myList1.Add("ACCT", 100, "1");
  myList1.Add("ACCT", 100, "2");
  myList1.Add("BUS", 101, "1"); and so on...
  </code></pre>
  
  <p>What I need to do is combine items that have the same curriculum and course so the sections are in one string.</p>
  
  <pre><code>"ACCT", 100, "1, 2"
  "BUS", 101, "1"
  </code></pre>
  
  <p>How should I go about comparing each item in the list to check for matches? The original method utilized a long chain of if-else statements and used 5 lists. I'm trying to avoid that. Is <a href="https://stackoverflow.com/questions/3216374/comparing-two-generic-lists-on-a-specific-property">this question</a> on the right track for me?</p>
  
  <p>EDIT: To answer Philipp's question, the list uses a class containing those properties like Thomas Levesque's answer:</p>
  
  <pre><code>class Course
  {
      public string Abbreviation { get; set; }
      public int Number { get; set; }
      public string Section { get; set; }
  }
  </code></pre>
  
  <p>And is populated by a method from a DataAccess class:</p>
  
  <pre><code>List&lt;Course&gt; list = DataAccess.GetData();
  </code></pre>
  
  <p>Hope that clears that up.</p>