Hashtable Key Limit

M

MFRASER

Is there a limit to the size of a key for a Hashtable. I am adding items to
a hashtable using a string for the key and it seems that when my key is 16
characters long the indexer does not work properly. If I truncate the key
to be 12 characters the indexer works.

Also is there a better way to build a key for a string, should I convert the
string to a numeric value then add it?

and if so how do I go about converting a string to a numeric value.
 
J

Jon Skeet [C# MVP]

MFRASER said:
Is there a limit to the size of a key for a Hashtable. I am adding items to
a hashtable using a string for the key and it seems that when my key is 16
characters long the indexer does not work properly. If I truncate the key
to be 12 characters the indexer works.

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.

There should be no problem using strings of any length.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top