In C#, if I create a hash table and get the memory address it's stored in, can I use that memory address in a different part of the program to recreate the hash table?
For example, can i do something like:
HashTable hash = new HashTable(oldHashPointer);
Yes and no. This isn't possible in C# in the way that you're describing it. For example the following code:
is essentially what you are trying to do, without explicit pointer usage.
HashTable bisn't a seperate entity, it's a pointer to the reference stored inHashTable a, which points to aHashTableobject in memory.This MSDN article elaborates on this. A quote from the page:
However, if you're trying to share objects between processes (in this case, a
HashTable), you could look into Memory Mapped Files. These will essentially allow you to write a serialized object into a virtual "file" residing in memory, that is also accessible from the other process. However, this is only available in .NET 4.0 or newer.