System.Collections.Specialized.NameValueCollection.Set Method

Sets the value of an entry in the System.Collections.Specialized.NameValueCollection.

Syntax

public virtual void Set (string name, string value)

Parameters

name
The string key of the entry to add the new value to. The key can be null.
value
The object that represents the new value to add to the specified entry. The value can be null.

Exceptions

TypeReason
NotSupportedExceptionThe current instance is read-only.

Remarks

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

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

This method is an O(1) operation.

Requirements

Namespace: System.Collections.Specialized
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0