LinkedList.System.Collections.Generic.ICollection<T>.Add Method 

Note: This method is new in the .NET Framework version 2.0.

Adds an item at the end of the ICollection.

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

void ICollection<TKey>.Add (
	T value
J# supports the use of explicit interface implementations, but not the declaration of new ones.
JScript supports the use of explicit interface implementations, but not the declarations of new ones.



The value to add at the end of the ICollection.

LinkedList accepts a null reference (Nothing in Visual Basic) as a valid Value for reference types and allows duplicate values.

If the LinkedList is empty, the new node becomes the First and the Last.

This method is an O(1) operation.

The following code example and output demonstrates that when a LinkedList is cast to ICollection, the LinkedList.System.Collections.Generic.ICollection<T>.Add method can be used to add a new node to the end of the linked list. The code example removes the last node in a linked list of strings, and adds a new node.

This code and output are part of a larger example provided for the LinkedList class.

        // When the linked list is cast to ICollection(Of String),
        // the Add method adds a node to the end of the list. 
        ICollection<string> icoll = sentence;
...//the quick brown dog jumped over the lazy rhinoceros

Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions