Hi, I've got a strange issue with handling hashtables of lists. App.vertexes is a hashtable of lists of longs. When I derefrence say App.vertexes[vert_B_index... ] and make changes to the list, it also changes values in App.vertexes of other keys in that hash table. Any help would be greatly appreciated, thanks in advance. Sid. Code (csharp): // update vert_B's segments Debug.Log ("vert_A_index: " + vert_A_index); Debug.Log ("vert_B_index: " + vert_B_index); List<long> vert_B_segments = (List<long>) App.vertexes[vert_B_index.ToString ()]; //vert_B_segments.Remove(seg_A_index); //vert_B_segments.Add(seg_B_index); //App.vertexes[ vert_B_index.ToString()] = vert_B_segments; List<long> vert_B_segments_test = (List<long>) App.vertexes[vert_B_index.ToString ()]; foreach ( long index in vert_B_segments_test ) Debug.Log ("vert_B_segments: " + index); List<long> vert_A_segments_test = (List<long>) App.vertexes[vert_A_index.ToString()]; foreach ( long index in vert_A_segments_test) { Debug.Log ("vert_A_segments: " + index); }
Solved.... turns out I was initialising the same list object into two keys in the hash table. Live and learn... putting the same object into static storage in more than one place will not create a clone.. but a reference to one single copy! Phew ... now I can move on .. yey!