Removing Duplicates from a List in C#

by Prashant 25. December 2009 03:25

For more details and detailed explaination of the code visit this link.

static List removeDuplicates(List inputList)
        {

            Dictionary uniqueStore = new Dictionary();
            List finalList = new List();
	    foreach (string currValue in inputList)
            {

                if (!uniqueStore.ContainsKey(currValue))
                {

                    uniqueStore.Add(currValue, 0);
                    finalList.Add(currValue);

                }

            }
            return finalList;
         }

If you enjoyed this post, make sure you subscribe to my RSS feed!

Share or Bookmark this post…
  • Live
  • Facebook
  • TwitThis
  • del.icio.us
  • Digg
  • DZone
  • Technorati
  • StumbleUpon
  • Google
  • E-Mail

Tags: , ,

.NET Framework | C#

Comments are closed

Powered by BlogEngine.NET 1.5.0.7
Visit blogadda.com to discover Indian blogs

Who am I?

Name of authorMy name is Prashant Khandelwal. I am a .NET programmer and technology enthusiast from New Delhi, India.

       

Tag Cloud

This will be shown to users with no Flash or Javascript.

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2010

Creative Commons License