Export (0) Print
Expand All

NameValueCollection.Add Method (String, String)

Adds an entry with the specified name and value to the NameValueCollection.

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

'Declaration
Public Overridable Sub Add ( _
	name As String, _
	value As String _
)
'Usage
Dim instance As NameValueCollection
Dim name As String
Dim value As String

instance.Add(name, value)
public void Add (
	String name, 
	String value
)
public function Add (
	name : String, 
	value : String
)
Not applicable.

Parameters

name

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

value

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

Exception typeCondition

NotSupportedException

The collection is read-only.

If the specified key already exists in the target NameValueCollection instance, the specified value is added to the existing comma-separated list of values associated with the same key in the target NameValueCollection instance.

If Count already equals the capacity, the capacity of the NameValueCollection is increased by automatically reallocating the internal array, and the existing elements are copied to the new array before the new element is added.

If Count is less than the capacity, this method is an O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count.

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