StringDictionary.Item Property (String)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the value associated with the specified key.

Namespace:   System.Collections.Specialized
Assembly:  System (in System.dll)

abstract Item : 
        key:string -> string with get, set
override Item : 
        key:string -> string with get, set

Parameters

key
Type: System.String

The key whose value to get or set.

Property Value

Type: System.String

The value associated with the specified key. If the specified key is not found, Get returns null, and Set creates a new entry with the specified key.

Exception Condition
ArgumentNullException

key is null.

The key is handled in a case-insensitive manner; it is translated to lowercase before it is used.

A key cannot be null, but a value can. To distinguish between null that is returned because the specified key is not found and null that is returned because the value of the specified key is null, use the ContainsKey method to determine if the key exists in the list.

The C# language uses the 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.

Retrieving the value of this property is an O(1) operation; setting the property is also an O(1) operation.

The following code example enumerates the elements of a StringDictionary.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Return to top
Show: