Does HybridDictionay key has to be string type?

  • Thread starter Thread starter Drasko
  • Start date Start date
D

Drasko

I am using HybridDictionry in my app, so it works fine if key is a string.
When I tried to make my class with ushort key, it throws ArgumentException?
First time when I add item it is ok, but when I try to add item with same
key, on Contains(serialNumber) it throws ArgumentException (first time it
passed it)?
What I am missing?

public class myDict
{

private HybridDictionary devices = new HybridDictionary(true);


public void Add( ushort serialNumber, Device device )

{

try

{


if(devices.Contains(serialNumber))

{

devices.Remove(serialNumber);

}

devices.Add( serialNumber, device );

}

catch (Exception ee)

{

string m = ee.Message;

}


// Indexer

public OMDevice this[ ushort serialNumber ]

{

get

{

return (Device) devices[serialNumber];

}

}

}
 
Drasko said:
I am using HybridDictionry in my app, so it works fine if key is a string.
When I tried to make my class with ushort key, it throws ArgumentException?
First time when I add item it is ok, but when I try to add item with same
key, on Contains(serialNumber) it throws ArgumentException (first time it
passed it)?
What I am missing?

Well, what did the exception say?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

I can't reproduce it at the moment, I'm afraid...
 
Back
Top