Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set collection preserving insertion order

Tags:

I need a collection that behaves as Set and preserves order of element insertion.

Is there one or I'll have to implement it myself?

What would the best implementation be?

like image 858
Konstantin Spirin Avatar asked Mar 05 '10 03:03

Konstantin Spirin


1 Answers

It doesn't exist in .NET, but you can emulate it using a List and the Distinct LINQ extension method, which should preserve the order of the underlying List.

like image 96
David Pfeffer Avatar answered Oct 11 '22 14:10

David Pfeffer