# OpcNodeReferenceCollection Members

> Reference: Provides a collection of OpcNodeReference instances where the NodeId is used as the key of each entry.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcNodeReferenceCollection</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx">Opc.UaFx</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

Inherits members from [KeyedCollection&lt;OpcNodeId, OpcNodeReference&gt;](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.keyedcollection-2), [Collection&lt;OpcNodeReference&gt;](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.collection-1).

## Constructors

### OpcNodeReferenceCollection

Initializes a new instance of the [OpcNodeReferenceCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/) class.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReferenceCollection()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New()
```

</div>

## Methods

### Add

<span class="api-meta">12 overloads</span>

| Overload | Description |
|---|---|
| [Add(IOpcNode, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-iopcnode-opc-uafx-opcnodeid) | Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing a bidirectional relation between the `sourceNode` and the node identified by the `targetNodeId` specified. |
| [Add(IOpcNode, OpcNodeId, OpcReferenceDirection?)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-iopcnode-opc-uafx-opcnodeid-system-nullable-of-opc-uafx-opcreferencedirection)<span class="api-meta">since v2.7</span> | Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the `sourceNode` and the target identified by the `targetNodeId` specified. |
| [Add(IOpcNode, OpcNodeId, OpcReferenceDirection?, OpcReferenceType)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-iopcnode-opc-uafx-opcnodeid-system-nullable-of-opc-uafx-opcreferencedirection-opc-uafx-opcreferencetype)<span class="api-meta">since v2.7</span> | Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the `sourceNode` and the target identified by the `targetNodeId` specified. |
| [Add(IOpcNode, OpcNodeId, OpcReferenceDirection?, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-iopcnode-opc-uafx-opcnodeid-system-nullable-of-opc-uafx-opcreferencedirection-opc-uafx-opcnodeid)<span class="api-meta">since v2.7</span> | Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the `sourceNode` and the target identified by the `targetNodeId` specified. |
| [Add(OpcNodeId, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-opcnodeid-opc-uafx-opcnodeid)<span class="api-meta">since v2.7</span> | Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing a bidirectional relation between the source identified by the `sourceNodeId` and the node identified by the `targetNodeId` specified. |
| [Add(OpcNodeId, OpcNodeId, OpcReferenceDirection?)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-opcnodeid-opc-uafx-opcnodeid-system-nullable-of-opc-uafx-opcreferencedirection)<span class="api-meta">since v2.7</span> | Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the source identified by `sourceNodeId` and the target identified by the `targetNodeId` specified. |
| [Add(OpcNodeId, OpcNodeId, OpcReferenceDirection?, OpcReferenceType)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-opcnodeid-opc-uafx-opcnodeid-system-nullable-of-opc-uafx-opcreferencedirection-opc-uafx-opcreferencetype)<span class="api-meta">since v2.7</span> | Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the source identified by the `sourceNodeId` and the target identified by the `targetNodeId` specified. |
| [Add(OpcNodeId, OpcNodeId, OpcReferenceDirection?, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-opcnodeid-opc-uafx-opcnodeid-system-nullable-of-opc-uafx-opcreferencedirection-opc-uafx-opcnodeid)<span class="api-meta">since v2.7</span> | Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the source identified by the `sourceNodeId` and the target identified by the `targetNodeId` specified. |
| [Add(IOpcNode, IEnumerable&lt;OpcReference&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-iopcnode-system-collections-generic-ienumerable-of-opc-uafx-opcreference)<span class="api-meta">since v2.7</span> | Adds a [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance representing a node / references bundle using the `node` and the `references` specified. |
| [Add(IOpcNode, params OpcReference\[\])](#add-opc-uafx-iopcnode-opc-uafx-opcreference-array)<span class="api-meta">since v2.7</span> | Adds a [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance representing a node / references bundle using the `node` and the `references` specified. |
| [Add(OpcNodeId, IEnumerable&lt;OpcReference&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereferencecollection/members#add-opc-uafx-opcnodeid-system-collections-generic-ienumerable-of-opc-uafx-opcreference)<span class="api-meta">since v2.7</span> | Adds a [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance representing a node / references bundle using the node identified by the `nodeId` and the `references` specified. |
| [Add(OpcNodeId, params OpcReference\[\])](#add-opc-uafx-opcnodeid-opc-uafx-opcreference-array)<span class="api-meta">since v2.7</span> | Adds a [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance representing a node / references bundle using the node identified by the `nodeId` and the `references` specified. |

#### Add(IOpcNode, OpcNodeId)

Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing a bidirectional relation between the `sourceNode` and the node identified by the `targetNodeId` specified. The references created represent a [ParentToChild](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/#parenttochild) and [ChildToParent](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/#childtoparent) relation using [Organizes](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/#organizes) as the type of reference.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference[] Add(IOpcNode sourceNode, OpcNodeId targetNodeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    sourceNode As IOpcNode,
    targetNodeId As OpcNodeId) As OpcNodeReference()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `sourceNode` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The source portion of the bidirectional reference defined between the passed [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) and the target identified by the `targetNodeId`. |
| `targetNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the target one reference will cease in, while the second reference uses it the other way round. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)[]

An array of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing the references added to the collection to define the bidirectional relation between the `sourceNode` and the target identified by the `targetNodeId`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `sourceNode` or `targetNodeId` is a null reference (Nothing in Visual Basic). |

#### Add(IOpcNode, OpcNodeId, OpcReferenceDirection?)

<span class="api-meta">since v2.7</span>

Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the `sourceNode` and the target identified by the `targetNodeId` specified. The references created depend on the value specified by `direction` using [Organizes](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/#organizes) as the type of reference.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference[] Add(
    IOpcNode sourceNode,
    OpcNodeId targetNodeId,
    OpcReferenceDirection? direction)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    sourceNode As IOpcNode,
    targetNodeId As OpcNodeId,
    direction As OpcReferenceDirection?) As OpcNodeReference()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `sourceNode` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The source portion of the references defined between the passed [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) and target identified by the `targetNodeId`. |
| `targetNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the target one reference will cease in, while the second reference uses it the other way round; if `direction` is a null reference (Nothing in Visual Basic). |
| `direction` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/)&gt; | One of the members defined by the [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) enumeration which defines the kind of unidirectional relation the reference will construct or a null reference (Nothing in Visual Basic) if bidirectional references shall be defined. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)[]

An array of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing the references addded to the collection to define the bidirectional or unidirectional relation between the `sourceNode` and the target identified by the `targetNodeId`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `sourceNode` or `targetNodeId` is a null reference (Nothing in Visual Basic). |

#### Add(IOpcNode, OpcNodeId, OpcReferenceDirection?, OpcReferenceType)

<span class="api-meta">since v2.7</span>

Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the `sourceNode` and the target identified by the `targetNodeId` specified. The references created depend on the value specified by `direction` using the `referenceType` as the type of reference.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference[] Add(
    IOpcNode sourceNode,
    OpcNodeId targetNodeId,
    OpcReferenceDirection? direction,
    OpcReferenceType referenceType)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    sourceNode As IOpcNode,
    targetNodeId As OpcNodeId,
    direction As OpcReferenceDirection?,
    referenceType As OpcReferenceType) As OpcNodeReference()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `sourceNode` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The source portion of the references defined between the passed [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) and target identified by the `targetNodeId`. |
| `targetNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the target one reference will cease in, while the second reference uses it the other way round; if `direction` is a null reference (Nothing in Visual Basic). |
| `direction` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/)&gt; | One of the members defined by the [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) enumeration which defines the kind of unidirectional relation the reference will construct or a null reference (Nothing in Visual Basic) if bidirectional references shall be defined. |
| `referenceType` | [OpcReferenceType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/) | One of the members defined by the [OpcReferenceType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/) enumeration to use to setup the type of reference represented. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)[]

An array of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing the references addded to the collection to define the bidirectional or unidirectional relation between the `sourceNode` and the target identified by the `targetNodeId`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `sourceNode` or `targetNodeId` is a null reference (Nothing in Visual Basic). |

#### Add(IOpcNode, OpcNodeId, OpcReferenceDirection?, OpcNodeId)

<span class="api-meta">since v2.7</span>

Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the `sourceNode` and the target identified by the `targetNodeId` specified. The references created depend on the value specified by `direction` using the type of reference identified by the `referenceTypeId` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference[] Add(
    IOpcNode sourceNode,
    OpcNodeId targetNodeId,
    OpcReferenceDirection? direction,
    OpcNodeId referenceTypeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    sourceNode As IOpcNode,
    targetNodeId As OpcNodeId,
    direction As OpcReferenceDirection?,
    referenceTypeId As OpcNodeId) As OpcNodeReference()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `sourceNode` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The source portion of the references defined between the passed [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) and target identified by the `targetNodeId`. |
| `targetNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the target one reference will cease in, while the second reference uses it the other way round; if `direction` is a null reference (Nothing in Visual Basic). |
| `direction` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/)&gt; | One of the members defined by the [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) enumeration which defines the kind of unidirectional relation the reference will construct or a null reference (Nothing in Visual Basic) if bidirectional references shall be defined. |
| `referenceTypeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the type of reference to represent between the target identified by the `targetNodeId` and its opponent. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)[]

An array of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing the references addded to the collection to define the bidirectional or unidirectional relation between the `sourceNode` and the target identified by the `targetNodeId`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `sourceNode` or `targetNodeId` is a null reference (Nothing in Visual Basic). |

#### Add(OpcNodeId, OpcNodeId)

<span class="api-meta">since v2.7</span>

Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing a bidirectional relation between the source identified by the `sourceNodeId` and the node identified by the `targetNodeId` specified. The references created represent a [ParentToChild](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/#parenttochild) and [ChildToParent](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/#childtoparent) relation using [Organizes](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/#organizes) as the type of reference.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference[] Add(OpcNodeId sourceNodeId, OpcNodeId targetNodeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    sourceNodeId As OpcNodeId,
    targetNodeId As OpcNodeId) As OpcNodeReference()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `sourceNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the source portion of the bidirectional reference defined between the passed [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) and the target identified by the `targetNodeId`. |
| `targetNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the target one reference will cease in, while the second reference uses it the other way round. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)[]

An array of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing the references added to the collection to define the bidirectional relation between the source identified by the `sourceNodeId` and the target identified by the `targetNodeId`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `sourceNodeId` or `targetNodeId` is a null reference (Nothing in Visual Basic). |

#### Add(OpcNodeId, OpcNodeId, OpcReferenceDirection?)

<span class="api-meta">since v2.7</span>

Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the source identified by `sourceNodeId` and the target identified by the `targetNodeId` specified. The references created depend on the value specified by `direction` using [Organizes](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/#organizes) as the type of reference.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference[] Add(
    OpcNodeId sourceNodeId,
    OpcNodeId targetNodeId,
    OpcReferenceDirection? direction)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    sourceNodeId As OpcNodeId,
    targetNodeId As OpcNodeId,
    direction As OpcReferenceDirection?) As OpcNodeReference()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `sourceNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the source portion of the references defined between the passed [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) and target identified by the `targetNodeId`. |
| `targetNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the target one reference will cease in, while the second reference uses it the other way round; if `direction` is a null reference (Nothing in Visual Basic). |
| `direction` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/)&gt; | One of the members defined by the [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) enumeration which defines the kind of unidirectional relation the reference will construct or a null reference (Nothing in Visual Basic) if bidirectional references shall be defined. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)[]

An array of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing the references addded to the collection to define the bidirectional or unidirectional relation between the source identified by the `sourceNodeId` and the target identified by the `targetNodeId`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `sourceNodeId` or `targetNodeId` is a null reference (Nothing in Visual Basic). |

#### Add(OpcNodeId, OpcNodeId, OpcReferenceDirection?, OpcReferenceType)

<span class="api-meta">since v2.7</span>

Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the source identified by the `sourceNodeId` and the target identified by the `targetNodeId` specified. The references created depend on the value specified by `direction` using the `referenceType` as the type of reference.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference[] Add(
    OpcNodeId sourceNodeId,
    OpcNodeId targetNodeId,
    OpcReferenceDirection? direction,
    OpcReferenceType referenceType)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    sourceNodeId As OpcNodeId,
    targetNodeId As OpcNodeId,
    direction As OpcReferenceDirection?,
    referenceType As OpcReferenceType) As OpcNodeReference()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `sourceNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the source portion of the references defined between the passed [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) and target identified by the `targetNodeId`. |
| `targetNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the target one reference will cease in, while the second reference uses it the other way round; if `direction` is a null reference (Nothing in Visual Basic). |
| `direction` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/)&gt; | One of the members defined by the [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) enumeration which defines the kind of unidirectional relation the reference will construct or a null reference (Nothing in Visual Basic) if bidirectional references shall be defined. |
| `referenceType` | [OpcReferenceType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/) | One of the members defined by the [OpcReferenceType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/) enumeration to use to setup the type of reference represented. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)[]

An array of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing the references addded to the collection to define the bidirectional or unidirectional relation between the source identified by the `sourceNodeId` and the target identified by the `targetNodeId`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `sourceNodeId` or `targetNodeId` is a null reference (Nothing in Visual Basic). |

#### Add(OpcNodeId, OpcNodeId, OpcReferenceDirection?, OpcNodeId)

<span class="api-meta">since v2.7</span>

Adds [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing either a bidirectional or a unidirectional relation between the source identified by the `sourceNodeId` and the target identified by the `targetNodeId` specified. The references created depend on the value specified by `direction` using the type of reference identified by the `referenceTypeId` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference[] Add(
    OpcNodeId sourceNodeId,
    OpcNodeId targetNodeId,
    OpcReferenceDirection? direction,
    OpcNodeId referenceTypeId)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    sourceNodeId As OpcNodeId,
    targetNodeId As OpcNodeId,
    direction As OpcReferenceDirection?,
    referenceTypeId As OpcNodeId) As OpcNodeReference()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `sourceNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the source portion of the references defined between the passed [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) and target identified by the `targetNodeId`. |
| `targetNodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the target one reference will cease in, while the second reference uses it the other way round; if `direction` is a null reference (Nothing in Visual Basic). |
| `direction` | [Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/)&gt; | One of the members defined by the [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) enumeration which defines the kind of unidirectional relation the reference will construct or a null reference (Nothing in Visual Basic) if bidirectional references shall be defined. |
| `referenceTypeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the type of reference to represent between the target identified by the `targetNodeId` and its opponent. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)[]

An array of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances representing the references addded to the collection to define the bidirectional or unidirectional relation between the source identified by the `sourceNodeId` and the target identified by the `targetNodeId`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `sourceNodeId` or `targetNodeId` is a null reference (Nothing in Visual Basic). |

#### Add(IOpcNode, IEnumerable&lt;OpcReference&gt;)

<span class="api-meta">since v2.7</span>

Adds a [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance representing a node / references bundle using the `node` and the `references` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference Add(IOpcNode node, IEnumerable<OpcReference> references)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    node As IOpcNode,
    references As IEnumerable(Of OpcReference)) As OpcNodeReference
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `node` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) used as the node to which the `references` specified belong to. |
| `references` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/)&gt; | A sequence of [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/) instances to associate with the node refered to by `node`. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)

A new instance of the [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) class which combines the `node` and the `references` specified.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `node` is a null reference (Nothing in Visual Basic). |

#### Add(IOpcNode, params OpcReference\[\])

<span class="api-meta">since v2.7</span>

Adds a [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance representing a node / references bundle using the `node` and the `references` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference Add(IOpcNode node, params OpcReference[] references)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    node As IOpcNode,
    ParamArray references As OpcReference()) As OpcNodeReference
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `node` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) used as the node to which the `references` specified belong to. |
| `references` | params [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/)[] | An array of [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/) instances to associate with the node refered to by `node`. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)

A new instance of the [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) class which combines the `node` and the `references` specified.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `node` is a null reference (Nothing in Visual Basic). |

#### Add(OpcNodeId, IEnumerable&lt;OpcReference&gt;)

<span class="api-meta">since v2.7</span>

Adds a [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance representing a node / references bundle using the node identified by the `nodeId` and the `references` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference Add(
    OpcNodeId nodeId,
    IEnumerable<OpcReference> references)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    nodeId As OpcNodeId,
    references As IEnumerable(Of OpcReference)) As OpcNodeReference
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `nodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the node to which the `references` specified belong to. |
| `references` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/)&gt; | A sequence of [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/) instances to associate with the node identified by the `nodeId`. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)

A new instance of the [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) class which combines the `nodeId` and the `references` specified.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `nodeId` is a null reference (Nothing in Visual Basic). |

#### Add(OpcNodeId, params OpcReference\[\])

<span class="api-meta">since v2.7</span>

Adds a [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance representing a node / references bundle using the node identified by the `nodeId` and the `references` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcNodeReference Add(OpcNodeId nodeId, params OpcReference[] references)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function Add(
    nodeId As OpcNodeId,
    ParamArray references As OpcReference()) As OpcNodeReference
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `nodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the node to which the `references` specified belong to. |
| `references` | params [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/)[] | An array of [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/) instances to associate with the node identified by the `nodeId`. |

**Returns**

[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)

A new instance of the [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) class which combines the `nodeId` and the `references` specified.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `nodeId` is a null reference (Nothing in Visual Basic). |

### GetKeyForItem

<span class="api-meta">protected · override</span>

Extracts the key from the specified element.

<div class="api-signature" data-lang="csharp">

```csharp
protected override OpcNodeId GetKeyForItem(OpcNodeReference item)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Protected Overrides Function GetKeyForItem(
    item As OpcNodeReference) As OpcNodeId
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `item` | [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) | The `item` from which to extract the key. |

**Returns**

[OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/)

The key for the specified `item`.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `item` is a null reference (Nothing in Visual Basic). |

**Overrides**

[GetKeyForItem(OpcNodeReference)](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.keyedcollection-2.getkeyforitem)
