I would like to know if there is any possible way to get an item from a hash table using a key that is identical to the actual key, but to a different object. I understand why this is probably not possible, but I would like to see if there is any complicated way to do this.
My problem arises from the fact that, being as stupid as I was, I created hash tables with int [] as keys with whole arrays containing indices representing the spatial position. I somehow knew that I needed to create a new int [] every time I wanted to add a new record, but I didnโt think that when I create spatial coordinate arrays later, they would be useless in extracting values โโfrom my hash tables .
Now I'm trying to decide if I need to reorder things so that I can store my values โโin ArrayLists or look in the key list in the Hashtable for the one that I need every time I want to get a value, no options are really cool.
Unless, of course, there is a way to make // 1 work like // 2!
Thanks in advance.
static void Main(string[] args)
{
Hashtable dog = new Hashtable();
int[] man = new int[] { 5 };
dog.Add(man, "hello");
int[] cat = new int[] { 5 };
Console.WriteLine(dog.ContainsKey(cat));
int boy = 5;
dog.Add(boy, "wtf");
int kitten = 5;
Console.WriteLine(dog.ContainsKey(kitten));
}
source
share