Hello
I defined:
Hashtable chan1 = new Hashtable(new
CaseInsensitiveHashCodeProvider(CultureInfo.Invari antCulture), new
InvariantComparer());
where:
public class InvariantComparer : IComparer
{
public CompareInfo m_compareInfo;
internal static readonly InvariantComparer Default = new
InvariantComparer();
internal InvariantComparer()
{
m_compareInfo = CultureInfo.InvariantCulture.CompareInfo;
}
public int Compare(Object a, Object b)
{/* compare my objects here */
DscRecord ra = a as DscRecord;
DscRecord rb = b as DscRecord;
if (ra.minute < rb.minute)
return 1;
else if (ra.minute > rb.minute)
return -1;
if (ra.second < rb.second)
return 1;
else if (ra.second > rb.second)
return -1;
if (ra.ssecond < rb.ssecond)
return 1;
else if (ra.ssecond > rb.ssecond)
return -1;
return 0;
}
}
but when i read data from hashtable:
IDictionaryEnumerator myEnumerator = chan.GetEnumerator();
while ( myEnumerator.MoveNext() )
{
......
}
i receive them "unsorted". Why ?
Is there any other way to read records from HashTable which is sorted by
key ?
Thanx
Michal