I have a dictionary like that:
There is no way to do that.
Note that hash collisions may occur, so there could be many keys in the
Dictionary<,> matching the given hash. We need
Equals to find out which (if any) is correct.
You talk about
new overhead. Are you sure it is significant in your case?
If it is, you could consider making
MyCompositeKey an immutable
struct instead of a
class. It might be faster in some cases, eliminating the need for the garbage collector to remove all those "loose" keys from memory.
MyCompositeKey is a
struct, the expression
new MyCompositeKey(params)) only loads all the
params onto the call stack (or CPU registers or whatever the run-time figures is best).