Reputation: 828
If I've got a dictionary and I get an item, is it's value or reference returned?
myDictionary.Add(myKey, myDictionaryObj)
Dim obj as myObject = myDictionary.Item(myKey)
will obj have the same value as myDictionaryObj or will it have it's reference?
Does it depend on the initial object?
Upvotes: 1
Views: 326
Reputation: 32597
You will get, what you have put into the dictionary.
If the dictionary's type is a reference type (e.g. classes), you will get a reference to the object, because only the reference is stored in the dictionary.
If the dictionary's type is a value type (e.g. structures), you will get a copy of the object, because the complete value is stored in the dictionary.
Upvotes: 3