Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
AddBefore Method (LinkedListNode(T), LinkedListNode(T))

LinkedList<T>.AddBefore Method (LinkedListNode<T>, LinkedListNode<T>)

Adds the specified new node before the specified existing node in the LinkedList<T>.

Namespace:  System.Collections.Generic
Assemblies:   System.Collections (in System.Collections.dll)
  System (in System.dll)

public void AddBefore(
	LinkedListNode<T> node,
	LinkedListNode<T> newNode
)

Parameters

node
Type: System.Collections.Generic.LinkedListNode<T>

The LinkedListNode<T> before which to insert newNode.

newNode
Type: System.Collections.Generic.LinkedListNode<T>

The new LinkedListNode<T> to add to the LinkedList<T>.

ExceptionCondition
ArgumentNullException

node is null.

-or-

newNode is null.

InvalidOperationException

node is not in the current LinkedList<T>.

-or-

newNode belongs to another LinkedList<T>.

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

This method is an O(1) operation.

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

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft