问题描述
给定一个Dictionary< object,object和一个对象,确实
复制原始对象的Equals和GetHashCode用作
字典键,如何检索使用的原始密钥?
given a Dictionary<object, objectand an object that exactly
replicates the Equals and GetHashCode of the original object used as
the dictionary key, how do I retrieve the original key that was used?
推荐答案
我相信OP意味着他有两个不同的对象(大概是
类)他认为是相同的 - 即它们代表相同的
客户,但是是不同的实例。他打算使用他手中的b $ b。找到在
字典中用作关键字的原文。在处理外墙,飞锤等时非常常见。
我以前见过这个,但我想我已经结束了
年我更喜欢使用灵长类钥匙......
Marc
I believe the OP means that he has two different objects (presumably
classes) that he considers equal - i.e. they represent the same
Customer, but are different instances. He intends to use the one he
has "in hand" to find the original that was used as the key in the
dictionary. Quite common when dealing with facades, flyweights, etc.
I have seen this done before, but I think I''ve concluded over the
years that I prefer to use primatives for keys...
Marc
这篇关于从字典中获取原始密钥对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!