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.
As per request, here is the relevant line from the log:
2010-03-08 22:58:00,504 [7] DEBUG Knickle.Framework.Routing.PageRoute (null) - Parameters: {System.String controller=null, System.String path=Page1, System.String path=/Page1, System.String action=null, System.String area=null}
Also, here I have added a line of code above the log printing call:
parameters.Add("path", "Page1");
Take a look in the log, and you'll notice that there are two "path" keys. The debugger shows both keys in different places in the table.