.net - Is it "bad" to use objects as Keys in dictionaries? -
i assume when doing look-up in dictionary needs hash key giving , use hash find object looking for.
if so, using larger objects keys slow down look-up or have other consequences not encountered using string or simple data type key?
yes, it's bad idea use mutable object dictionary key.
taking @ https://stackoverflow.com/a/7941876/400760, leads me believe there unintended consequences, correctly implemented gethashcode() based on how hash based collections typically implemented.
it should safe use immutable object dictionary key.
Comments
Post a Comment