# OpcReadOnlyNodeCollection Members

> Reference: Provides a read-only collection of IOpcNode instances accessible by their Id or just using an index.

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

## Properties

### Count

Gets the number of nodes contained in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/) instance.

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

```csharp
public int Count { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Count As Integer
```

</div>

**Property value**

[Int32](https://learn.microsoft.com/dotnet/api/system.int32)

The number of nodes contained in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/) instance.

**Implements**

[Count](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.count), [Count](https://learn.microsoft.com/dotnet/api/system.collections.icollection.count)

### Empty

<span class="api-meta">static</span>

Gets an empty instance used in cases there the concrete collection does not yet exists.

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

```csharp
public static OpcReadOnlyNodeCollection Empty { get; }
```

</div>

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

```vbnet
Public Shared ReadOnly Property Empty As OpcReadOnlyNodeCollection
```

</div>

**Property value**

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

An instance of the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/) which can be used for general purpose in cases there an empty collection is required.

### Items

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

Gets the [IList&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1) that the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/) wraps.

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

```csharp
protected IList<IOpcNode> Items { get; }
```

</div>

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

```vbnet
Protected ReadOnly Property Items As IList(Of IOpcNode)
```

</div>

**Property value**

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

The [IList&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1) that the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/) wraps.

## Methods

### Contains

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

| Overload | Description |
|---|---|
| [Contains(IOpcNode)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/members#contains-opc-uafx-iopcnode) | Determines whether a node is in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/). |
| [Contains(OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/members#contains-opc-uafx-opcnodeid) | Determines whether a node with the `id` specified is in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/). |

#### Contains(IOpcNode)

Determines whether a node is in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/).

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

```csharp
public bool Contains(IOpcNode value)
```

</div>

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

```vbnet
Public Function Contains(value As IOpcNode) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The object to locate in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/). |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if value is found in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/); otherwise, the value false.

**Exceptions**

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

**Implements**

[Contains(IOpcNode)](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.contains)

#### Contains(OpcNodeId)

Determines whether a node with the `id` specified is in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/).

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

```csharp
public bool Contains(OpcNodeId id)
```

</div>

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

```vbnet
Public Function Contains(id As OpcNodeId) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `id` | [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/) to use to look up a existing node. |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if a node exists in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/) with the `id`; otherwise, the value false.

**Exceptions**

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

### CopyTo

Copies the entire [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/) to a compatible one-dimensional [Array](https://learn.microsoft.com/dotnet/api/system.array), starting at the specified `index` of the target `array`.

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

```csharp
public void CopyTo(IOpcNode[] array, int index)
```

</div>

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

```vbnet
Public Sub CopyTo(array As IOpcNode(), index As Integer)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `array` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/)[] | The one-dimensional [Array](https://learn.microsoft.com/dotnet/api/system.array) that is the destination of the elements copied from [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/). The [Array](https://learn.microsoft.com/dotnet/api/system.array) must have zero-based indexing. |
| `index` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero-based index in array at which copying begins. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The number of elements in the source [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/) is greater than the available space from `index` to the end of the destination `array`. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `array` is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `index` is less than zero. |

**Implements**

[CopyTo(IOpcNode\[\], int)](https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1.copyto)

### GetEnumerator

Returns an enumerator that iterates through the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/).

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

```csharp
public IEnumerator<IOpcNode> GetEnumerator()
```

</div>

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

```vbnet
Public Function GetEnumerator() As IEnumerator(Of IOpcNode)
```

</div>

**Returns**

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

An [IEnumerator&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerator-1) for the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/).

**Implements**

[GetEnumerator()](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1.getenumerator)

### IndexOf

Searches for the specified object and returns the zero-based index of the first occurrence within the entire [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/).

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

```csharp
public int IndexOf(IOpcNode value)
```

</div>

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

```vbnet
Public Function IndexOf(value As IOpcNode) As Integer
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | The node to locate in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/). |

**Returns**

[Int32](https://learn.microsoft.com/dotnet/api/system.int32)

The zero-based index of the first occurrence of item within the entire `value`, if found; otherwise the value -1.

**Exceptions**

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

**Implements**

[IndexOf(IOpcNode)](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1.indexof)

### TryGet

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

Tries to determine the item associated with the specified `id`.

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

```csharp
public bool TryGet(OpcNodeId id, out IOpcNode node)
```

</div>

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

```vbnet
Public Function TryGet(id As OpcNodeId, node As IOpcNode) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `id` | [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/) whose [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) item to get. |
| `node` | out [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) | When this method returns, the [IOpcNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnode/) associated with the specified `id`, if the `id` is found; otherwise, a null reference (Nothing in Visual Basic). |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

**Exceptions**

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

## Indexers

### Item

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

| Overload | Description |
|---|---|
| [this\[int\]](#item-system-int32) | Gets the node at the specified index. |
| [this\[OpcNodeId\]](#item-opc-uafx-opcnodeid) | Gets the node at the specified index. |

#### this\[int\]

Gets the node at the specified index.

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

```csharp
public IOpcNode this[int index] { get; }
```

</div>

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

```vbnet
Public ReadOnly Default Property this[](index As Integer) As IOpcNode
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `index` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero-based index of the node to get. |

**Property value**

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

The node at the specified index.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `index` is not valid index in the [OpcReadOnlyNodeCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynodecollection/). |

#### this\[OpcNodeId\]

Gets the node at the specified index.

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

```csharp
public IOpcNode this[OpcNodeId id] { get; }
```

</div>

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

```vbnet
Public ReadOnly Default Property this[](id As OpcNodeId) As IOpcNode
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `id` | [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 node to get. |

**Property value**

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

The node with the specified `id`.

**Exceptions**

| Exception | Condition |
|---|---|
| [KeyNotFoundException](https://learn.microsoft.com/dotnet/api/system.collections.generic.keynotfoundexception) | The `id` does not refer to a node with such an [Id](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcnodeinfo/members#id). |
