Duplicate items in a list 
Author Message
 Duplicate items in a list

Hi,

I'm using Array and ArrayList in my C# program and I wonder if there was a
way to remove duplicate without me programming it.

Thank you !

Carl Tremblay



Mon, 12 Jul 2004 02:35:25 GMT  
 Duplicate items in a list
Carl,

    No, there isn't.  However, it shouldn't be that hard to do really, using
the Sort method and some comparison functions.  If maintaining the order is
important, then I would recommend a traversal through the array, using the
items as keys for a hashtable.  Then, when you come across an element that
already exists in the hashtable, you can skip it when adding it to a new
array list.

    Hope this helps.

--
                              - Nicholas Paldino [.NET MVP]


Quote:
> Hi,

> I'm using Array and ArrayList in my C# program and I wonder if there was a
> way to remove duplicate without me programming it.

> Thank you !

> Carl Tremblay



Mon, 12 Jul 2004 02:50:46 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Remove duplicated items in an ArrayList

2. SortedList with duplicate items?

3. Duplicate item in dataset

4. Duplicate menu items

5. duplicated items in ComboBox

6. Duplicate menu items

7. Could some-one explain why the result of my query list duplicate ChannelID's

8. list wouldnt sort and remove duplicates

9. duplicating VC IDE list selection

10. List Box - Add item does option does not exist as in VB.

11. Last Item in DataTable not bound to Drop Down List

12. Deleting items froma linked list

 

 
Powered by phpBB® Forum Software