.NET Hashtable - "Same" key, different hashes
Posted
by Simon Lindgren
on Stack Overflow
See other posts from Stack Overflow
or by Simon Lindgren
Published on 2010-03-08T21:48:20Z
Indexed on
2010/03/08
21:51 UTC
Read the original article
Hit count: 344
Is it possible for two .net strings to have different hashes? I have a Hashtable with amongst others the key "path". When I loop through the elements in the table to print it, i can see that the key exists.
When trying to looking it up however, there is no matching element. Debugging suggests that the string I'm looking for has a different hash than the one I'm supplying as the key.
This code is in a Castle Monorail project, using brail as a view engine. The key I'm looking for is inserted by a brail line like this:
UrlHelper.Link(node.CurrentPage.LinkText, {@params: {@path: "/Page1"}})
Then, in this method (in a custom IRoutingRule):
public string CreateUrl(System.Collections.IDictionary parameters)
{
PrintDictionaryToLog(parameters);
string url;
if (parameters.Contains("path")) {
url = (string)parameters["path"];
}
else {
return null;
}
}
The key is printed to the log, but the function returns null. I didn't know this could even be a problem with .net strings, but I guess this is some kind of encoding issue?
Oh, and this is running mono.
© Stack Overflow or respective owner