What is the most elegant way to find index of duplicate items in C# List

Posted by user326559 on Stack Overflow See other posts from Stack Overflow or by user326559
Published on 2010-04-27T04:53:19Z Indexed on 2010/04/27 5:03 UTC
Read the original article Hit count: 304

Filed under:
|
|
|

I've got a List that contains duplicates and I need to find the indexes of each.

What is the most elegant, efficient way other than looping through all the items. I'm on .NET 4.0 so LINQ is an option. I've done tons of searching and connect find anything.

Sample data:

var data = new List{"fname", "lname", "home", "home", "company"}();

I need to get the indexes of "home".

© Stack Overflow or respective owner

Related posts about c#

Related posts about list