This property provides the ability to access a specific element in the collection by using the following C# syntax: myCollection[key] (myCollection(key) in Visual Basic).
You can also use the Item property to add new elements by setting the value of a key that does not exist in the Dictionary<(Of <(TKey, TValue>)>). When you set the property value, if the key is in the Dictionary<(Of <(TKey, TValue>)>), the value associated with that key is replaced by the assigned value. If the key is not in the Dictionary<(Of <(TKey, TValue>)>), the key and value are added to the dictionary. In contrast, the Add method does not modify existing elements.
A key cannot be nullNothingnullptra null reference (Nothing in Visual Basic), but a value can be, if the value type TValue is a reference type.
The C# language uses the this keyword to define the indexers instead of implementing the Item property. Visual Basic implements Item as a default property, which provides the same indexing functionality.
Getting or setting the value of this property approaches an O(1) operation.