# ExtensionObjectExtensions Members

> Reference: Provides extension methods for the ExtensionObject class.

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

## Methods

### To

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

Retrieves the body of the `extensionObject` as an instance of `T`.

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

```csharp
public static T To<T>(this ExtensionObject extensionObject)
```

</div>

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

```vbnet
Public Shared Function [To](Of T)(extensionObject As ExtensionObject) As T
```

</div>

**Type parameters**

| Name | Description |
|---|---|
| `T` | The type of the instance stored in the body. |

**Parameters**

| Name | Type | Description |
|---|---|---|
| `extensionObject` | <abbr title="OPC Foundation stack type, not documented here: Opc.Ua.ExtensionObject">ExtensionObject</abbr> | The <abbr title="OPC Foundation stack type, not documented here: Opc.Ua.ExtensionObject">ExtensionObject</abbr> whose body is to be retrieved. |

**Returns**

T

The instance of `T` stored in the body of the `extensionObject`.

**Exceptions**

| Exception | Condition |
|---|---|
| [InvalidCastException](https://learn.microsoft.com/dotnet/api/system.invalidcastexception) | The body of the `extensionObject` is not an instance of `T`. |

**Remarks**

If the body holds an instance of `T` decoded by the SDK, the decoded instance is returned instead of the body itself.
