473,326 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Does HybridDictionay key has to be string type?

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];

}

}

}
Nov 16 '05 #1
2 1150
Drasko <dr***********@ri-ing.hr> wrote:
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...

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Drasko <dr***********@ri-ing.hr> wrote:
Hello Jon, thanks for your answer. I find out that when I use
casenonsesitive hybriddictionary it seems to work fine!

But here is the code:


That still isn't reproducing the problem for me. Then again, it isn't a
complete program (nor is it as short as it could be, and the formatting
makes it very hard to read). Please see
http://www.pobox.com/~skeet/csharp/incomplete.html

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Bob Day | last post by:
VS 2003 The documentation says " Nothing keyword represents the default value of any data type" this is simply not true and causing a lot of problems. 1) Consider an SQL table of 3 columns: ...
0
by: Richard Gregory | last post by:
Hi, I have the wsdl below, for an Axis web service, and when I select Add Web Refernce in Visual Studio the proxy is missing a class representing the returnedElementsType (see reference.cs below...
0
by: =?Utf-8?B?Sm9iIExvdA==?= | last post by:
I have created Exception Handling Policy that shows a custom error message using Custom Handler and logs it to event log using Logging Handler. I am using this policy in various layers of my...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.