Skip to content

Instantly share code, notes, and snippets.

@brilligence
Last active December 15, 2015 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brilligence/5207217 to your computer and use it in GitHub Desktop.
Save brilligence/5207217 to your computer and use it in GitHub Desktop.
internal class Program
{
// Sample unordered list of strings
private const string OriginalString = "[V],[E],[B],[B],[O],[E],[P],[B]";
private static void Main(string[] args)
{
var lst = new List<string>();
lst.AddRange(OriginalString.Split(','));
// Getting duplicate entries from the unordered list
var duplicates = lst.GetDuplicates();
// Check if the List<string> extension method works
if (duplicates.Count > 0)
{
Assert.AreEqual(2, duplicates.Count);
Assert.IsTrue(duplicates.Contains("[E]"));
Assert.IsTrue(duplicates.Contains("[B]"));
}
else
{
Assert.AreEqual(0, duplicates.Count);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment