Export (0) Print
Expand All

NameValueCollection.Item Property (String)

Gets or sets the entry with the specified key in the NameValueCollection.

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

'Declaration
Public Default Property Item ( _
	name As String _
) As String
'Usage
Dim instance As NameValueCollection
Dim name As String
Dim value As String

value = instance(name)

instance(name) = value
/** @property */
public String get_Item (String name)

/** @property */
public void set_Item (String name, String value)

Not applicable.

Parameters

name

The String key of the entry to locate. The key can be a null reference (Nothing in Visual Basic).

Property Value

A String that contains the comma-separated list of values associated with the specified key, if found; otherwise, a null reference (Nothing in Visual Basic).

Exception typeCondition

NotSupportedException

The collection is read-only and the operation attempts to modify the collection.

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

If the specified key already exists in the collection, setting this property overwrites the existing list of values with the specified value. To append the new value to the existing list of values, use the Add method.

If the specified key does not exist in the collection, setting this property creates a new entry using the specified key and the specified value.

Caution noteCaution:

This property returns a null reference (Nothing in Visual Basic) in the following cases: 1) if the specified key is not found; and 2) if the specified key is found and its associated value is a null reference (Nothing in Visual Basic). This property does not distinguish between the two cases.

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.

Retrieving or setting the values associated with the specified key is an O(n) operation, where n is the number of values.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft