.NET Hashtable - "Same" key, different hashes
- by Simon Lindgren
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.