Check if there are no repeats in the list

I have a list called com, which contains a bunch of integers. I need to check the list to make sure that each integer only exists once in the list. So if:


I need have some code to check that 1 is represented twice as well as 3. This is my best guess on how to solve it:

for (int j = 0; j < com.Count; j++)
            if (com.Contains(com[j]))
                lion += 1;
                lion = 0;

But it doesn't work. Can anybody out there help me??


Here's a simple, but probably not that efficient way using LINQ:

using System.Linq;


bool containsRepeats = com.Count() != com.Distinct().Count();

Need Your Help

Mercurial - getting changes from other repository


We have a Mercurial repository on BitBucket. This repository is used by a bunch of people.

Need to embed a “confirmation link” in an email sent from AS3/PHP

php mysql actionscript-3 email confirmation

So a component in an app I'm currently developing sends a confirmation email to whoever the user puts in as their "emergency contact" which simply states that the user has chosen them to be the con...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.