Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

LinkedList<T>.AddFirst Method

Definition

Namespace:
System.Collections.Generic
Assemblies:
System.dll, System.Collections.dll
Assemblies:
netstandard.dll, System.Collections.dll
Assembly:
System.Collections.dll
Assembly:
System.dll
Assembly:
netstandard.dll

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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

Overloads

Name Description
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>)

Source:
LinkedList.cs
Source:
LinkedList.cs
Source:
LinkedList.cs
Source:
LinkedList.cs
Source:
LinkedList.cs

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)

Source:
LinkedList.cs
Source:
LinkedList.cs
Source:
LinkedList.cs
Source:
LinkedList.cs
Source:
LinkedList.cs

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


Feedback

Was this page helpful?