# OpcReference Members

> Reference: Describes a unidirectional reference from a logical 'parent' to a logical 'child' or vice versa using a specific type of reference between the two opponents.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcReference</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>

## Constructors

### OpcReference

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

| Overload | Description |
|---|---|
| [OpcReference(IOpcNode, OpcReferenceDirection, OpcReferenceType)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/members#opcreference-opc-uafx-iopcnode-opc-uafx-opcreferencedirection-opc-uafx-opcreferencetype)<span class="api-meta">since v2.7</span> | Initializes a new instance of the [OpcBidirectionalReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcbidirectionalreference/) class using the `targetNode` as the target of the reference and using the value of the `type` parameter as the type of reference in the relation defined by `direction`. |
| [OpcReference(IOpcNode, OpcReferenceDirection, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/members#opcreference-opc-uafx-iopcnode-opc-uafx-opcreferencedirection-opc-uafx-opcnodeid)<span class="api-meta">since v2.7</span> | Initializes a new instance of the [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/) class using the `targetNode` as the target using the type of reference identified by the `typeId` specified in the relation defined by `direction`. |
| [OpcReference(OpcNodeId, OpcReferenceDirection, OpcReferenceType)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/members#opcreference-opc-uafx-opcnodeid-opc-uafx-opcreferencedirection-opc-uafx-opcreferencetype)<span class="api-meta">since v2.7</span> | Initializes a new instance of the [OpcBidirectionalReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcbidirectionalreference/) class using the `targetNodeId` as the identifier of the target of the reference using the value of the `type` parameter as the type of the reference in the relation defined by `direction`. |
| [OpcReference(OpcNodeId, OpcReferenceDirection, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/members#opcreference-opc-uafx-opcnodeid-opc-uafx-opcreferencedirection-opc-uafx-opcnodeid)<span class="api-meta">since v2.7</span> | Initializes a new instance of the [OpcBidirectionalReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcbidirectionalreference/) class using the `targetNodeId` as the identifier of the target and using the type of reference identified by the `typeId` specified in the relation defined by `direction`. |

#### OpcReference(IOpcNode, OpcReferenceDirection, OpcReferenceType)

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

Initializes a new instance of the [OpcBidirectionalReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcbidirectionalreference/) class using the `targetNode` as the target of the reference and using the value of the `type` parameter as the type of reference in the relation defined by `direction`.

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

```csharp
public OpcReference(
    IOpcNode targetNode,
    OpcReferenceDirection direction,
    OpcReferenceType type)
```

</div>

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

```vbnet
Public Sub New(
    targetNode As IOpcNode,
    direction As OpcReferenceDirection,
    type As OpcReferenceType)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `targetNode` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The [IOpcNodeInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnodeinfo/) in which the reference constructed ceases. |
| `direction` | [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) | 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 relation the reference defines. |
| `type` | [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. |

**Exceptions**

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

#### OpcReference(IOpcNode, OpcReferenceDirection, OpcNodeId)

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

Initializes a new instance of the [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/) class using the `targetNode` as the target using the type of reference identified by the `typeId` specified in the relation defined by `direction`.

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

```csharp
public OpcReference(
    IOpcNode targetNode,
    OpcReferenceDirection direction,
    OpcNodeId typeId)
```

</div>

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

```vbnet
Public Sub New(
    targetNode As IOpcNode,
    direction As OpcReferenceDirection,
    typeId As OpcNodeId)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `targetNode` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The [IOpcNodeInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnodeinfo/) in which the reference constructed ceases. |
| `direction` | [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) | 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 relation the reference defines. |
| `typeId` | [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 `targetNode` and its opponent. |

**Exceptions**

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

#### OpcReference(OpcNodeId, OpcReferenceDirection, OpcReferenceType)

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

Initializes a new instance of the [OpcBidirectionalReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcbidirectionalreference/) class using the `targetNodeId` as the identifier of the target of the reference using the value of the `type` parameter as the type of the reference in the relation defined by `direction`.

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

```csharp
public OpcReference(
    OpcNodeId targetNodeId,
    OpcReferenceDirection direction,
    OpcReferenceType type)
```

</div>

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

```vbnet
Public Sub New(
    targetNodeId As OpcNodeId,
    direction As OpcReferenceDirection,
    type As OpcReferenceType)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `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 node in which the reference constructed ceases. |
| `direction` | [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) | 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 relation the reference defines. |
| `type` | [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. |

**Exceptions**

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

#### OpcReference(OpcNodeId, OpcReferenceDirection, OpcNodeId)

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

Initializes a new instance of the [OpcBidirectionalReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcbidirectionalreference/) class using the `targetNodeId` as the identifier of the target and using the type of reference identified by the `typeId` specified in the relation defined by `direction`.

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

```csharp
public OpcReference(
    OpcNodeId targetNodeId,
    OpcReferenceDirection direction,
    OpcNodeId typeId)
```

</div>

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

```vbnet
Public Sub New(
    targetNodeId As OpcNodeId,
    direction As OpcReferenceDirection,
    typeId As OpcNodeId)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `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 node in which the reference constructed ceases. |
| `direction` | [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) | 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 relation the reference defines. |
| `typeId` | [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. |

**Exceptions**

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

## Properties

### Direction

Gets a value indicating the logical direction of the reference represented.

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

```csharp
public OpcReferenceDirection Direction { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Direction As OpcReferenceDirection
```

</div>

**Property value**

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

One of the members defined by the [OpcReferenceDirection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/) enumeration. The default value is [ParentToChild](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencedirection/#parenttochild).

### TargetNode

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

Gets the node to which the reference refers to.

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

```csharp
public IOpcNode TargetNode { get; }
```

</div>

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

```vbnet
Public ReadOnly Property TargetNode As IOpcNode
```

</div>

**Property value**

[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/) to which the reference refers to or a null refernce (Nothing in Visual Basic) in case there this [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/) has been initialized using a [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) which identifies the node the reference refers to.

### TargetNodeId

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

Gets the identifier of the node to which the reference refers to.

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

```csharp
public OpcNodeId TargetNodeId { get; }
```

</div>

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

```vbnet
Public ReadOnly Property TargetNodeId As OpcNodeId
```

</div>

**Property value**

[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 reference refers to.

### Type

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

Gets a value which defines the pre-defined type of reference represented.

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

```csharp
public OpcReferenceType? Type { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Type As OpcReferenceType?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcReferenceType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/)&gt;

One of the members defined by the [OpcReferenceType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/) enumeration or a null reference (Nothing in Visual Basic) if [TypeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/members#typeid) refers to a type of reference which is not a built in reference type. The default value is [Organizes](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetype/#organizes).

### TypeId

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

Gets the identifier which identifies the node that defines the semantic of the reference between the source and the target node represented through this [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/) and generally reflects an operation between the two, such as "A contains B".

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

```csharp
public OpcNodeId TypeId { get; }
```

</div>

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

```vbnet
Public ReadOnly Property TypeId As OpcNodeId
```

</div>

**Property value**

[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/) of the reference type node which defines the relation semantic between the source and the target node. The default value is [Organizes](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreferencetypes/members#organizes).

## Methods

### GetReferences

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

| Overload | Description |
|---|---|
| [GetReferences()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/members#getreferences-noparams)<span class="api-meta">since v2.7</span> | Retrieves an empty sequence of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances. |
| [GetReferences(IOpcNode)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/members#getreferences-opc-uafx-iopcnode)<span class="api-meta">since v2.7</span> | Retrieves a sequence with one [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance using the `node` specified as the source of the reference. |
| [GetReferences(OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/members#getreferences-opc-uafx-opcnodeid)<span class="api-meta">since v2.7</span> | Retrieves a sequence with one [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance using the `nodeId` specified as the source of the reference. |

#### GetReferences()

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

Retrieves an empty sequence of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances.

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

```csharp
public IEnumerable<OpcNodeReference> GetReferences()
```

</div>

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

```vbnet
Public Function GetReferences() As IEnumerable(Of OpcNodeReference)
```

</div>

**Returns**

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)&gt;

An empty [IEnumerable&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances.

**Implements**

[GetReferences](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnodereferenceaware/members#getreferences-noparams)

#### GetReferences(IOpcNode)

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

Retrieves a sequence with one [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance using the `node` specified as the source of the reference.

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

```csharp
public IEnumerable<OpcNodeReference> GetReferences(IOpcNode node)
```

</div>

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

```vbnet
Public Function GetReferences(
    node As IOpcNode) As IEnumerable(Of 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/) instance from which the [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance originates from. |

**Returns**

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)&gt;

An [IEnumerable&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances which contains only one instance.

**Exceptions**

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

**Implements**

[GetReferences](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnodereferenceaware/members#getreferences-opc-uafx-iopcnode)

#### GetReferences(OpcNodeId)

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

Retrieves a sequence with one [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance using the `nodeId` specified as the source of the reference.

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

```csharp
public IEnumerable<OpcNodeReference> GetReferences(OpcNodeId nodeId)
```

</div>

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

```vbnet
Public Function GetReferences(
    nodeId As OpcNodeId) As IEnumerable(Of 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 from which the [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instance originates from. |

**Returns**

[IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/)&gt;

An [IEnumerable&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1) of [OpcNodeReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodereference/) instances which contains only one instance.

**Exceptions**

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

**Implements**

[GetReferences](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnodereferenceaware/members#getreferences-opc-uafx-opcnodeid)

### ToString

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

Returns a string representing the information contained in the [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/).

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

```csharp
public override string ToString()
```

</div>

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

```vbnet
Public Overrides Function ToString() As String
```

</div>

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)

A string which describes the information in this [OpcReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreference/).

**Overrides**

[ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)
