[Mono-list] HashSet does not preserve add order

Jonathan Pryor jonpryor at vt.edu
Sat Jan 24 13:59:20 EST 2009

On Sat, 2009-01-24 at 20:44 +0200, Andrus wrote:
> Code below produces different results in MONO and .NET .
> How to fix ?

>From [0]:

        A set is a collection that contains no duplicate elements, and
        whose elements are in no particular order.

It *explicitly* states that elements are in no order, thus it is not
portable to assume that the order is in fact consistent.

You can't fix the code.  You're depending on an implementation detail,
subject to change without notice.  

 - Jon

[0] http://msdn.microsoft.com/en-us/library/bb359438.aspx

More information about the Mono-list mailing list