When I add some items into a Java Hashtable
, their order is different to that of a .NET Hashtable
. Is there any way I can make sure the .NET Hashtable
will have the same order as a Java Hashtable
?
I'm trying to port some Java code to C#. The Java code uses a Hashtable
to keep track of some data. When I check to see the order the data is retrieved when I iterate through either the Java Hashtable
or the .NET Hashtable
(via an Enumerator
), each one consistently has the same data, in the same order ... but each code based has a different order.
Is there any way I can make it so that the .NET Hashtable
data is in the same order as the Java Hashtable
?
I understand that Hashtable
do not handling ordering - so I feel like there's nothing that can be done. I also cannot change the datatype in the Java code from .. say .. a Hashtable
to something else.
Here's some same data to illustrate my situation.
Data, added sequential for either code base :-
- num | someData
- pagenum | someData
- x | someData
- top | someData
Java Code:
private Hashtable identifiers = new Hashtable();
...
identifiers.put(symbol, identifier);
Java output via iteration over an enumerator:
.NET code:
private Hashtable Identifiers = new Hashtable();
...
Identifiers.Add(symbol, identifier);
.NET output via iteration over an enumerator.
Any ideas or suggestions?