# C# - Removing Duplicates from List

**URL:** <https://forum.kirupa.com/t/c-removing-duplicates-from-list/206674>\
**Category:** open source\
**Created:** [November 10, 2006, 6:49am UTC](https://forum.kirupa.com/t/c-removing-duplicates-from-list/206674 "2006-11-10T06:49:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [November 10, 2006, 6:49am UTC](https://forum.kirupa.com/t/c-removing-duplicates-from-list/206674/1 "2006-11-10T06:49:01Z")

</div>

```auto
[SIZE=2][COLOR=#000000]static List<string> removeDuplicates(List<string> inputList)
{
    Dictionary<string, int> uniqueStore = new Dictionary<string, int>();
    List<string> finalList = new List<string>();[/COLOR][/SIZE]
[SIZE=2][COLOR=#000000] foreach (string currValue in inputList)
    {
        if (!uniqueStore.ContainsKey(currValue))
        {
            uniqueStore.Add(currValue, 0);
            finalList.Add(currValue);
        }
    }
    return finalList;[/COLOR][/SIZE]
[SIZE=2]}[/SIZE]

```

[SIZE=2]This code basically takes in a list of strings and returns a new list with all duplicate strings removed. It might come in handy :P[/SIZE]

[SIZE=2]Cheers![/SIZE]  
[SIZE=2]Kirupa :rambo: [/SIZE]
