# OpcDictionary&lt;TKey, TValue&gt; Members

> Reference: Represents a collection of keys and values which can be used as a data type in OPC UA.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcDictionary&lt;TKey, TValue&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 [Dictionary&lt;TKey, TValue&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2).

## Constructors

### OpcDictionary

Initializes a new instance of the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) class that is empty, has the default initial capacity, and uses the default equality comparer for the key type.

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

```csharp
public OpcDictionary()
```

</div>

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

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

</div>

## Methods

### RegisterType

<span class="api-meta">static · 3 overloads</span>

| Overload | Description |
|---|---|
| [RegisterType()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/members#registertype-noparams)<span class="api-meta">static</span> | Registers the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) using the `TKey` and `TValue` to define a non-generic encodable data object type to create in case there a data instance is to be created for the type definition identified by the combination of [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/), `TKey` and `TValue` (on which this method is called) within the namespace index with the number two. |
| [RegisterType(OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/members#registertype-opc-uafx-opcnodeid)<span class="api-meta">static</span> | Registers the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) using the `TKey` and `TValue` to define a non-generic encodable data object type to create in case there a data instance is to be created for the type definition identified by the `dataTypeId` specified. |
| [RegisterType(OpcNodeId, params OpcEncoding\[\])](#registertype-opc-uafx-opcnodeid-opc-uafx-opcencoding-array)<span class="api-meta">static</span> | Registers the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) using the `TKey` and `TValue` to define a non-generic encodable data object type to create in case there a data instance is to be created for the type definition identified by the `dataTypeId` or by one of the `dataTypeEncodings` specified. |

#### RegisterType()

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

Registers the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) using the `TKey` and `TValue` to define a non-generic encodable data object type to create in case there a data instance is to be created for the type definition identified by the combination of [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/), `TKey` and `TValue` (on which this method is called) within the namespace index with the number two. This is e.g. for [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) with `TKey` equals [int](https://learn.microsoft.com/dotnet/api/system.int32) and `TValue` equals [string](https://learn.microsoft.com/dotnet/api/system.string) "ns=2;s=OpcDictionary&lt;Int32, String&gt;". The according encoding information is then used as follows "ns=2;s=OpcDictionary&lt;Int32, String&gt;/Default Binary".

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

```csharp
public static void RegisterType()
```

</div>

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

```vbnet
Public Shared Sub RegisterType()
```

</div>

#### RegisterType(OpcNodeId)

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

Registers the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) using the `TKey` and `TValue` to define a non-generic encodable data object type to create in case there a data instance is to be created for the type definition identified by the `dataTypeId` specified.

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

```csharp
public static void RegisterType(OpcNodeId dataTypeId)
```

</div>

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

```vbnet
Public Shared Sub RegisterType(dataTypeId As OpcNodeId)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `dataTypeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the type definition for which the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) is to be used to create a data object instance. |

**Exceptions**

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

#### RegisterType(OpcNodeId, params OpcEncoding\[\])

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

Registers the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) using the `TKey` and `TValue` to define a non-generic encodable data object type to create in case there a data instance is to be created for the type definition identified by the `dataTypeId` or by one of the `dataTypeEncodings` specified.

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

```csharp
public static void RegisterType(
    OpcNodeId dataTypeId,
    params OpcEncoding[] dataTypeEncodings)
```

</div>

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

```vbnet
Public Shared Sub RegisterType(
    dataTypeId As OpcNodeId,
    ParamArray dataTypeEncodings As OpcEncoding())
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `dataTypeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the type definition for which the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) is to be used to create a data object instance. |
| `dataTypeEncodings` | params [OpcEncoding](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencoding/)[] | An array of [OpcEncoding](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencoding/) instances identifying the different encodings supported by the [OpcDictionary&lt;TKey, TValue&gt;](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/) specified. Using [OpcEncoding](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencoding/) instances enables the possibility to define [OpcEncodingType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingtype/) specific identifiers to use to identify the according encoding information required to encode or decode the data object information. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `dataTypeId` or `dataTypeEncodings` or one of its items is a null reference (Nothing in Visual Basic). |
