I have a method whose output I'll be caching. It takes four parameters; string
, string
, int
, and WindowsIdentity
. I need to create a cache key based on those four parameters. Is it best to:
Concatenate them all together as strings and use that key?
var key = string.Concat(string1, string2, int1.ToString(), identity.ToString());
Or
Xor together their hash codes?
var key = string1.GetHashCode() ^ string2.GetHashCode() ^ int1.GetHashCode() ^ identity.GetHashCode();
Or something else? Does it matter? In my particular case, these keys will just be going into a Hashtable (C# v1).