Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove duplicate in a list
private static List<T> RemoveDoubleItems<T>(List<T> list)
{
var newList = new List<T>();
var keyList = new Dictionary<T,string>();
foreach (T item in list)
{
if (!keyList.ContainsKey(item))
{
keyList.Add(item, string.Empty);
newList.Add(item);
}
}
return newList;
}
private static List<T> RemoveDoubleItems<T>(List<T> list)
{
return list.Distinct().ToList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.