A Question about dictionaries.

I have a dictionary whose key is an object and whose value is an array of objects.
When I receive a new key and object to add to the dictionary if the key already exists in the dictionary then the object is to be appended to the value.
The problem I’m facing is the first time I add a key and object to the dictionary the value will be an instance of the object rather than an array of objects.

dim dict as new Dictionary

1st time.
dim marr(-1) as Message // New… Right?
marr.append(newMessage)
dict.Value(key) = marr

2nd time
dim marr(-1) as Message // New?
marr = dict.Value(key)
marr.append(newMessage)
//I guess I don’t need to do anything else…

dim marr(-1) as Message creates a reference to an array. You can either create the array by appending, as you do the first time, or you can point it to an existing array, as you do the second time.

I guess the 2nd time that the new array that is created is very quickly destroyed and replaced by the one in the dictionary.

I don’t think it actually creates an array.