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

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

<dl class="api-definition">
<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>Members</dt>
<dd><a href="./members">OpcDictionary&lt;TKey, TValue&gt; Members</a></dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

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

## Syntax

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

```csharp
public sealed class OpcDictionary<TKey, TValue> : Dictionary<TKey, TValue>
```

</div>

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

```vbnet
<OpcDataTypeMembers(OpcMemberOrigins.Field Or OpcMemberOrigins.Explicit Or OpcMemberOrigins.Private)>
Public NotInheritable Class OpcDictionary(Of TKey, TValue)
    Inherits Dictionary(Of TKey, TValue)
```

</div>

## Type parameters

| Name | Description |
|---|---|
| `TKey` | The type of the keys in the dictionary which needs to be a known data type in OPC UA. |
| `TValue` | The type of the values in the dictionary which needs to be a known data type in OPC UA. |

## Inheritance

[Object](https://learn.microsoft.com/dotnet/api/system.object) → [Dictionary](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2)&lt;TKey, TValue&gt; → **OpcDictionary&lt;TKey, TValue&gt;**

## Implements

<ul class="api-implements">
<li><a href="https://learn.microsoft.com/dotnet/api/system.collections.icollection">ICollection</a></li>
<li><a href="https://learn.microsoft.com/dotnet/api/system.collections.generic.icollection-1">ICollection</a>&lt;<a href="https://learn.microsoft.com/dotnet/api/system.collections.generic.keyvaluepair-2">KeyValuePair</a>&lt;TKey, TValue&gt;&gt;</li>
<li><a href="https://learn.microsoft.com/dotnet/api/system.runtime.serialization.ideserializationcallback">IDeserializationCallback</a></li>
<li><a href="https://learn.microsoft.com/dotnet/api/system.collections.idictionary">IDictionary</a></li>
<li><a href="https://learn.microsoft.com/dotnet/api/system.collections.generic.idictionary-2">IDictionary</a>&lt;TKey, TValue&gt;</li>
<li><a href="https://learn.microsoft.com/dotnet/api/system.collections.ienumerable">IEnumerable</a></li>
<li><a href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;<a href="https://learn.microsoft.com/dotnet/api/system.collections.generic.keyvaluepair-2">KeyValuePair</a>&lt;TKey, TValue&gt;&gt;</li>
<li><a href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlycollection-1">IReadOnlyCollection</a>&lt;<a href="https://learn.microsoft.com/dotnet/api/system.collections.generic.keyvaluepair-2">KeyValuePair</a>&lt;TKey, TValue&gt;&gt;</li>
<li><a href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlydictionary-2">IReadOnlyDictionary</a>&lt;TKey, TValue&gt;</li>
<li><a href="https://learn.microsoft.com/dotnet/api/system.runtime.serialization.iserializable">ISerializable</a></li>
</ul>

## Remarks

Using the OpcDictionary&lt;TKey, TValue&gt; requires an OPC UA server which defines the according non-generic type which uses specific type arguments for `TKey` and `TValue`. A client application in turn have to manually define the server defined / used combination of the generic OpcDictionary&lt;TKey, TValue&gt; type and its specific type arguments for `TKey` and `TValue`.

## Constructors

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

## Methods

| Name | Description |
|---|---|
| [RegisterType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdictionary-2/members#registertype)<span class="api-meta">static · 3 overloads</span> | Registers the OpcDictionary&lt;TKey, TValue&gt; 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;, `TKey` and `TValue` (on which this method is called) within the namespace index with the number two. |

Inherits members from [Dictionary&lt;TKey, TValue&gt;](https://learn.microsoft.com/dotnet/api/system.collections.generic.dictionary-2).

## Applies to

| Package | Versions |
|---|---|
| Opc.UaFx.Advanced | v2.9–v2.59 |
