This documentation is archived and is not being maintained.

StringCollection.System.Collections.IList.Add Method

Adds an object to the end of the StringCollection.

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

int IList.Add (
	Object value
Not applicable.



The Object to be added to the end of the StringCollection. The value can be a null reference (Nothing in Visual Basic).

Return Value

The StringCollection index at which the value has been added.

Exception typeCondition


The StringCollection is read-only.


The StringCollection has a fixed size.

StringCollection accepts a null reference (Nothing in Visual Basic) as a valid value and allows duplicate elements.

If Count already equals the capacity, the capacity of the StringCollection 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 Millennium Edition, 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