title: Use foreach loop to find duplicate in Observable Collection
body: <p>I'm trying to find all the duplicates in my ObservableCollection, using Lambda/LINQ
  Say I have my <code>ObservableCollection&lt;Student&gt; studentList</code></p>
  <p>Each Student has fields</p>
  <pre><code>Name
  Age
  Class
  </code></pre>
  <p>Now in the list, say the following is input in the list</p>
  <pre><code>studentList.Add(new Student()
      {
          Name = Name,
          Age= Age,
          Class = Class
      });
  </code></pre>
  <p>Each time the user enters the data and clicks the button, the data is added. So in my list I would have (as an example)</p>
  <blockquote>
  <p>Bob, 6, Blue Class</p>
  <p>Jerry 8, Red Class</p>
  <p>Andy 7, Red Class</p>
  <p>Bob, 10, Red Class</p>
  </blockquote>
  <p>I would like to loop through the list and find out which names are duplicates
  So far my code is:</p>
  <pre><code>bool cont = false;
  foreach (var dup in studentList)
      {
          if (!studentList.Any(x =&gt; x.Name== dup.Name))
              {
                  cont = true;
              }
              else
              {
                  cont = false;
                  break;
              }
      }
  </code></pre>
  <p>But something is not right. It will always &quot;Bob&quot; in the if statement.
  And if I entered 4 completley different names, it would still say false. It takes the last entered value and always compares it to that one, never actually checking them all.</p>
  <p>It is a bit hard to explain. If I knew where the problem lie, I would be of more help.</p>
  <p>All I would like is to loop through my list to find matching values, and to set the bool to false and break the loop, so that the user can be notified and can make changes before they continue. And I would like the solution to be in a Lambda/LINQ statement</p>