This documentation is archived and is not being maintained.

NameValueCollection.Set Method

Sets the value of an entry in the NameValueCollection.

[Visual Basic]
Public Overridable Sub Set( _
   ByVal name As String, _
   ByVal value As String _
public virtual void Set(
 string name,
 string value
public: virtual void Set(
 String* name,
 String* value
public function Set(
   name : String,
 value : String


The String key of the entry to add the new value to. The key can be a null reference (Nothing in Visual Basic).
The Object that represents the new value to add to the specified entry. The value can be a null reference (Nothing in Visual Basic).


Exception Type Condition
NotSupportedException The collection is read-only.


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 Add 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.


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

See Also

NameValueCollection Class | NameValueCollection Members | System.Collections.Specialized Namespace | Add | Performing Culture-Insensitive String Operations