We had one hashtable as a readonly reference to a list of values like this:
internal static readonly Hashtable relationcodeAcodeB = new Hashtable
{
{"149", "23"},
{"139", "17"}
}
Now we need an structure that can hold 3 values(columns) and look up a value fast by any of the other 2.
Something like this:
internal static readonly Hashtable relationcodeAcodeBcodeC = new Hashtable
{
{"149", "23", "xx"},
{"139", "17", "xxx"}
}
string codeB=relationcodeAcodeBcodeC[codeA="149"]["codeB"];
Say your object has three properties codeA, codeB and codeC, you maintain three hash tables, like so:
Dictionary<string, MyObj> dictA, dictB, dictC;
When creating a new MyObj
, you add it to the three dictionaries:
dictA[obj.codeA] = obj;
dictB[obj.codeB] = obj;
dictC[obj.codeC] = obj;
Looking up is very easy. Your example will be coded as dictA["149"].codeB
Keep it all tidy in one big lookup class, of course.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With