LinkedList<T>.AddFirst Method

Definition

Adds a new node or value at the start of the LinkedList<T>.

Overloads

AddFirst(LinkedListNode<T>)

Adds the specified new node at the start of the LinkedList<T>.

AddFirst(T)

Adds a new node containing the specified value at the start of the LinkedList<T>.

AddFirst(LinkedListNode<T>)

Adds the specified new node at the start of the LinkedList<T>.

public:
 void AddFirst(System::Collections::Generic::LinkedListNode<T> ^ node);
public void AddFirst (System.Collections.Generic.LinkedListNode<T> node);
member this.AddFirst : System.Collections.Generic.LinkedListNode<'T> -> unit
Public Sub AddFirst (node As LinkedListNode(Of T))

Parameters

node
LinkedListNode<T>

The new LinkedListNode<T> to add at the start of the LinkedList<T>.

Exceptions

node is null.

node belongs to another LinkedList<T>.

Examples

For an example that includes this method, see the LinkedList<T> class.

Remarks

LinkedList<T> accepts null as a valid Value for reference types and allows duplicate values.

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

This method is an O(1) operation.

See also

Applies to

AddFirst(T)

Adds a new node containing the specified value at the start of the LinkedList<T>.

public:
 System::Collections::Generic::LinkedListNode<T> ^ AddFirst(T value);
public System.Collections.Generic.LinkedListNode<T> AddFirst (T value);
member this.AddFirst : 'T -> System.Collections.Generic.LinkedListNode<'T>
Public Function AddFirst (value As T) As LinkedListNode(Of T)

Parameters

value
T

The value to add at the start of the LinkedList<T>.

Returns

The new LinkedListNode<T> containing value.

Examples

For an example that includes this method, see the LinkedList<T> class.

Remarks

LinkedList<T> accepts null as a valid Value for reference types and allows duplicate values.

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

This method is an O(1) operation.

See also

Applies to