Hello,
Here is some code:
I'm thinking that when storing an object in an ArrayList or Hashtable
that it clones the object. This can be shown like so:
// key is a generated hashcode for this function (its unique).
public struct Test {
int m_state;
}
p_newItem.m_state = 0; // Set the state
m_myHash.Add( (object) key, (object) p_newItem); // Store the object in
the hashtable
p_newItem.m_state = 1; // Now change the value
Test t = (Test) m_myHash[ (object) key ];
Console.WriteLine( t.m_state ); // != 1 its still 0!!
What is going on here? My only guess is that the object is stored as a
clone of the original. Not as a reference as I would expect.