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!

Tags: , ,

.NET Framework | C# | Code Snippets

Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


Visit blogadda.com to discover Indian blogs Computers Blogs

About Me

Name of authorPrashant Khandelwal.
Programmer and tech enthusiast. More...

Feeds Subscribe Twitter Facebook Google Plus Linked In Delicious

My Visual Studio Achievements

Badges

Month List

Blog Stats

321,799 Hits

Adverts

Disclaimer

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

© Copyright 2012

Creative Commons License