Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IDictionary.Item Property

When implemented by a class, gets or sets the element with the specified key.

[C#] In C#, this property is the indexer for the IDictionary class.

[Visual Basic]
Default Property Item( _
   ByVal key As Object _
) As Object
object this[
   object key
] {get; set;}
__property Object* get_Item(
 Object* key
__property void set_Item(
 Object* key,
returnValue = IDictionaryObject.Item(key);
IDictionaryObject.Item(key) = returnValue;
returnValue = IDictionaryObject(key);
IDictionaryObject(key) = returnValue;

[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed property whose type is Object and whose index type is String.

Arguments [JScript]

The key of the element to get or set.

Parameters [Visual Basic, C#, C++]

The key of the element to get or set.

Property Value

The element with the specified key.


Exception Type Condition
ArgumentNullException key is a null reference (Nothing in Visual Basic).
NotSupportedException The property is set and the IDictionary is read-only.


The property is set, key does not exist in the collection, and the IDictionary has a fixed size.


This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[key].

When setting this property, if the specified key already exists in the dictionary, the value is replaced; otherwise, a new element is created. In contrast, the Add method does not modify existing elements.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Common Language Infrastructure (CLI) Standard

See Also

IDictionary Interface | IDictionary Members | System.Collections Namespace | Add

© 2016 Microsoft