# OpcCollection&lt;TItem, TItemContent, TItemContentList&gt; Members

> Reference: Provides an abstract generic base class for IOpcContainer items their content is maintained in a different list which is to be used as the content of the collection like TItem uses the TItemContent instances in TItemContentList.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcCollection&lt;TItem, TItemContent, TItemContentList&gt;</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 [Collection&lt;TItem&gt;](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.collection-1).

## Constructors

### OpcCollection

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

| Overload | Description |
|---|---|
| [OpcCollection()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccollection-3/members#opccollection-noparams)<span class="api-meta">protected</span> | Initializes a new instance of the [OpcCollection&lt;TItem, TItemContent, TItemContentList&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccollection-3/) class. |
| [OpcCollection(IList&lt;TItem&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccollection-3/members#opccollection-system-collections-generic-ilist-of-t0)<span class="api-meta">protected</span> | Initializes a new instance of the [OpcCollection&lt;TItem, TItemContent, TItemContentList&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccollection-3/) class as a wrapper for the specified `list`. |

#### OpcCollection()

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

Initializes a new instance of the [OpcCollection&lt;TItem, TItemContent, TItemContentList&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccollection-3/) class.

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

```csharp
protected OpcCollection()
```

</div>

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

```vbnet
Protected Sub New()
```

</div>

#### OpcCollection(IList&lt;TItem&gt;)

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

Initializes a new instance of the [OpcCollection&lt;TItem, TItemContent, TItemContentList&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccollection-3/) class as a wrapper for the specified `list`.

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

```csharp
protected OpcCollection(IList<TItem> list)
```

</div>

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

```vbnet
Protected Sub New(list As IList(Of TItem))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `list` | [IList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1)&lt;TItem&gt; | The [IList&lt;T&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1) of `TItem` instances to wrap. |

**Exceptions**

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

## Methods

### ClearItems

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

Removes all elements from the [OpcCollection&lt;TItem, TItemContent, TItemContentList&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccollection-3/).

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

```csharp
protected override void ClearItems()
```

</div>

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

```vbnet
Protected Overrides Sub ClearItems()
```

</div>

**Overrides**

[ClearItems()](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.collection-1.clearitems)

### InsertItem

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

Inserts an element into the [OpcCollection&lt;TItem, TItemContent, TItemContentList&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccollection-3/) at the specified index.

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

```csharp
protected override void InsertItem(int index, TItem item)
```

</div>

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

```vbnet
Protected Overrides Sub InsertItem(index As Integer, item As TItem)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `index` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero-based index at which the item should be inserted. |
| `item` | TItem | The object to insert. |

**Overrides**

[InsertItem(int, TItem)](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.collection-1.insertitem)

### RemoveItem

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

Removes the element at the specified index of the [OpcCollection&lt;TItem, TItemContent, TItemContentList&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccollection-3/).

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

```csharp
protected override void RemoveItem(int index)
```

</div>

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

```vbnet
Protected Overrides Sub RemoveItem(index As Integer)
```

</div>

**Parameters**

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

**Overrides**

[RemoveItem(int)](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.collection-1.removeitem)

### SetItem

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

Replaces the element at the specified index.

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

```csharp
protected override void SetItem(int index, TItem item)
```

</div>

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

```vbnet
Protected Overrides Sub SetItem(index As Integer, item As TItem)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `index` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero-based index of the element to replace. |
| `item` | TItem | The new value for the element at the specified index. |

**Overrides**

[SetItem(int, TItem)](https://learn.microsoft.com/dotnet/api/system.collections.objectmodel.collection-1.setitem)
