title: Comparing Two Lists C#
body: <p>Alright, so I'm trying to compare two lists with a method to display the new items in the second list.  The lists are hard coded in and in separate methods to print out on the console.  The only way I've managed to be able to pull every entry from both lists is using a foreach loop but it always goes to the statement that each entry is not equal even when the entries are the exact same.  I'm not sure why this happening.</p>
  
  <p>Here are the two coded lists</p>
  
  <pre><code>    public static List&lt;Student&gt; GetStudentsOld()
      {
          List&lt;Student&gt; student = new List&lt;Student&gt;();
  
          student.Add(new Student("111", "Michael", "Tucker", "Junior", 10));
          student.Add(new Student("222", "Svetlana", "Omelchenko", "Senior", 2));
          student.Add(new Student("333", "Michiko", "Osada", "Senior", 7));
          student.Add(new Student("444", "Hugo", "Garcia", "Junior", 16));
          student.Add(new Student("555", "Cesar", "Garcia", "Freshman", 4));
          student.Add(new Student("666", "Fadi", "Fakhouri", "Senior", 72));
          student.Add(new Student("777", "Hanying", "Feng", "Senior", 11));
          student.Add(new Student("888", "Debra", "Garcia", "Junior", 41));
          student.Add(new Student("999", "Terry", "Adams", "Senior", 6));
          student.Add(new Student("211", "Bob", "Stephenson", "Junior", 150));
          return student;
      }
  
      public static List&lt;Student&gt; GetStudentsNew()
      {
          List&lt;Student&gt; students = new List&lt;Student&gt;();
  
          students.Add(new Student("111", "Michael", "Tucker", "Junior", 10));
          students.Add(new Student("222", "Svetlana", "Omelchenko", "Senior", 2));
          students.Add(new Student("333", "Michiko", "Osada", "Senior", 7));
          students.Add(new Student("311", "Sven", "Mortensen", "Freshman", 53));
          students.Add(new Student("444", "Hugo", "Garcia", "Freshman", 16));
          students.Add(new Student("555", "Cesar", "Garcia", "Freshman", 4));
          students.Add(new Student("666", "Fadi", "Fakhouri", "Senior", 72));
          students.Add(new Student("777", "Hanying", "Feng", "Senior", 11));
          students.Add(new Student("888", "Debra", "Garcia", "Junior", 41));
          students.Add(new Student("411", "Lance", "Tucker", "Junior", 60));
          students.Add(new Student("999", "Terry", "Adams", "Senior", 6));
          return students;
      }
  </code></pre>
  
  <p>and here is the method I've tried to compare the two lists</p>
  
  <pre><code>    public static void StudentIDMatch(List&lt;Student&gt; students, List&lt;Student&gt; student)
      {
  
  
          foreach (var ID in students)
          {
              bool isMatch = false;
              do
  
                  foreach (var ID2 in student)
                  {
                      if (ID2 != ID)
                      {
  
                          isMatch = false;
                      }
                      else if (ID.Equals(ID2))
                      {
                          isMatch = false;
                      }
                  }
              while (!isMatch);
  
          }
      }
  </code></pre>
  
  <p>ultimately I'm trying to find the differences and print them out.  I know it's not complete but I need to figure out how to compare them correctly before I start to tackle how to get them printed out.  Also I know the Do While loop isn't correct and I need to redo that as well after this gets fixed.</p>
  
  <p>Thanks!</p>