Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the specified entry of the NameValueCollection.
Item[Int32] |
Gets the entry at the specified index of the NameValueCollection. |
Item[String] |
Gets or sets the entry with the specified key in the NameValueCollection. |
Gets the entry at the specified index of the NameValueCollection.
public:
property System::String ^ default[int] { System::String ^ get(int index); };
public string this[int index] { get; }
public string? this[int index] { get; }
member this.Item(int) : string
Default Public ReadOnly Property Item(index As Integer) As String
The zero-based index of the entry to locate in the collection.
A String that contains the comma-separated list of values at the specified index of the collection.
index
is outside the valid range of indexes for the collection.
This property provides the ability to access a specific element in the collection by using the following syntax: myCollection[index]
.
This property cannot be set. To set the value at a specified index, use Item[GetKey(index)]
.
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 the values at the specified index is an O(n
) operation, where n
is the number of values.
Gets or sets the entry with the specified key in the NameValueCollection.
public:
property System::String ^ default[System::String ^] { System::String ^ get(System::String ^ name); void set(System::String ^ name, System::String ^ value); };
public string this[string name] { get; set; }
public string? this[string? name] { get; set; }
member this.Item(string) : string with get, set
Default Public Property Item(name As String) As String
A String that contains the comma-separated list of values associated with the specified key, if found; otherwise, null
.
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
This property returns null
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 null
. 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.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in