# OpcStruct Members

> Reference: Defines a structured data type at runtime, e.g. to provide it by a server using Create.

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

### BaseId

Gets the identifier of the base data type of the structure.

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

```csharp
public OpcNodeId BaseId { get; }
```

</div>

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

```vbnet
Public ReadOnly Property BaseId As OpcNodeId
```

</div>

**Property value**

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

The identifier of the base data type; the identifier of the Structure data type for a structure defined using [DefineType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/members#definetype-opc-uafx-opcname-opc-uafx-opcstructfield-array).

### EncodingMask

Gets the encoding mask of the structure.

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

```csharp
public OpcEncodingMask EncodingMask { get; }
```

</div>

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

```vbnet
Public ReadOnly Property EncodingMask As OpcEncodingMask
```

</div>

**Property value**

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

The encoding mask set using [WithEncodingMask](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/members#withencodingmask), or a null reference (Nothing in Visual Basic) if none has been set; then [DefaultAuto](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmask/members#defaultauto) is used.

### Encodings

Gets the encodings of the structure.

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

```csharp
public OpcEncoding[] Encodings { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Encodings As OpcEncoding()
```

</div>

**Property value**

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

The encodings set using [WithEncodings](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/members#withencodings), or a null reference (Nothing in Visual Basic) if none have been set; then all encodings of the identifier of the data type are used.

### Id

Gets the identifier of the structure.

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

```csharp
public OpcNodeId Id { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Id As OpcNodeId
```

</div>

**Property value**

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

The identifier of the structure, or [Null](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/members#null) if none has been specified.

**Implements**

[Id](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatatypebuilder/members#id)

### Name

Gets the name of the structure.

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

```csharp
public OpcName Name { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Name As OpcName
```

</div>

**Property value**

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

The name of the structure.

**Implements**

[Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatatypebuilder/members#name)

## Methods

### CreateTypeInfo

Creates the type information of the structure using the `context` and the `typeId` specified.

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

```csharp
public IOpcDataTypeInfo CreateTypeInfo(OpcContext context, OpcNodeId typeId)
```

</div>

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

```vbnet
Public Function CreateTypeInfo(
    context As OpcContext,
    typeId As OpcNodeId) As IOpcDataTypeInfo
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `context` | [OpcContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccontext/) | The context used to resolve the data types of the base type and of the fields. |
| `typeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the data type to create. |

**Returns**

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

The type information of the structure.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `context` or the `typeId` is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The data type of an array field is not known by the `context`. |

**Implements**

[CreateTypeInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatatypebuilder/members#createtypeinfo)

**Remarks**

The data types of the fields are resolved using the `context` while the type information is created. A field whose data type is the `typeId` refers to the structure itself. The name of the structure is placed in the namespace of the `typeId`.

### DefineSubType

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

| Overload | Description |
|---|---|
| [DefineSubType(OpcNodeId, OpcName, params OpcStructField\[\])](#definesubtype-opc-uafx-opcnodeid-opc-uafx-opcname-opc-uafx-opcstructfield-array)<span class="api-meta">static</span> | Defines a structure derived from the base data type specified. |
| [DefineSubType(OpcNodeId, OpcName, IEnumerable&lt;OpcStructField&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/members#definesubtype-opc-uafx-opcnodeid-opc-uafx-opcname-system-collections-generic-ienumerable-of-opc-uafx-opcstructfield)<span class="api-meta">static</span> | Defines a structure derived from the base data type specified. |
| [DefineSubType(OpcNodeId, OpcNodeId, OpcName, params OpcStructField\[\])](#definesubtype-opc-uafx-opcnodeid-opc-uafx-opcnodeid-opc-uafx-opcname-opc-uafx-opcstructfield-array)<span class="api-meta">static</span> | Defines a structure with the identifier specified derived from the base data type specified. |
| [DefineSubType(OpcNodeId, OpcNodeId, OpcName, IEnumerable&lt;OpcStructField&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/members#definesubtype-opc-uafx-opcnodeid-opc-uafx-opcnodeid-opc-uafx-opcname-system-collections-generic-ienumerable-of-opc-uafx-opcstructfield)<span class="api-meta">static</span> | Defines a structure with the identifier specified derived from the base data type specified. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `baseId`, the `name` or the `fields` or one of its elements is a null reference (Nothing in Visual Basic). |

#### DefineSubType(OpcNodeId, OpcName, params OpcStructField\[\])

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

Defines a structure derived from the base data type specified.

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

```csharp
public static OpcStruct DefineSubType(
    OpcNodeId baseId,
    OpcName name,
    params OpcStructField[] fields)
```

</div>

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

```vbnet
Public Shared Function DefineSubType(
    baseId As OpcNodeId,
    name As OpcName,
    ParamArray fields As OpcStructField()) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `baseId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the base data type of the structure. |
| `name` | [OpcName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcname/) | The name of the structure. |
| `fields` | params [OpcStructField](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstructfield/)[] | The fields of the structure in the order of their encoding. |

**Returns**

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

A new [OpcStruct](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/) which defines the structure.

#### DefineSubType(OpcNodeId, OpcName, IEnumerable&lt;OpcStructField&gt;)

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

Defines a structure derived from the base data type specified.

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

```csharp
public static OpcStruct DefineSubType(
    OpcNodeId baseId,
    OpcName name,
    IEnumerable<OpcStructField> fields)
```

</div>

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

```vbnet
Public Shared Function DefineSubType(
    baseId As OpcNodeId,
    name As OpcName,
    fields As IEnumerable(Of OpcStructField)) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `baseId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the base data type of the structure. |
| `name` | [OpcName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcname/) | The name of the structure. |
| `fields` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcStructField](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstructfield/)&gt; | The fields of the structure in the order of their encoding. |

**Returns**

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

A new [OpcStruct](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/) which defines the structure.

#### DefineSubType(OpcNodeId, OpcNodeId, OpcName, params OpcStructField\[\])

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

Defines a structure with the identifier specified derived from the base data type specified.

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

```csharp
public static OpcStruct DefineSubType(
    OpcNodeId baseId,
    OpcNodeId id,
    OpcName name,
    params OpcStructField[] fields)
```

</div>

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

```vbnet
Public Shared Function DefineSubType(
    baseId As OpcNodeId,
    id As OpcNodeId,
    name As OpcName,
    ParamArray fields As OpcStructField()) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `baseId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the base data type of the structure. |
| `id` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the structure. |
| `name` | [OpcName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcname/) | The name of the structure. |
| `fields` | params [OpcStructField](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstructfield/)[] | The fields of the structure in the order of their encoding. |

**Returns**

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

A new [OpcStruct](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/) which defines the structure.

#### DefineSubType(OpcNodeId, OpcNodeId, OpcName, IEnumerable&lt;OpcStructField&gt;)

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

Defines a structure with the identifier specified derived from the base data type specified.

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

```csharp
public static OpcStruct DefineSubType(
    OpcNodeId baseId,
    OpcNodeId id,
    OpcName name,
    IEnumerable<OpcStructField> fields)
```

</div>

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

```vbnet
Public Shared Function DefineSubType(
    baseId As OpcNodeId,
    id As OpcNodeId,
    name As OpcName,
    fields As IEnumerable(Of OpcStructField)) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `baseId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the base data type of the structure. |
| `id` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the structure. |
| `name` | [OpcName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcname/) | The name of the structure. |
| `fields` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcStructField](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstructfield/)&gt; | The fields of the structure in the order of their encoding. |

**Returns**

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

A new [OpcStruct](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/) which defines the structure.

### DefineType

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

| Overload | Description |
|---|---|
| [DefineType(OpcName, params OpcStructField\[\])](#definetype-opc-uafx-opcname-opc-uafx-opcstructfield-array)<span class="api-meta">static</span> | Defines a structure derived from the Structure data type. |
| [DefineType(OpcName, IEnumerable&lt;OpcStructField&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/members#definetype-opc-uafx-opcname-system-collections-generic-ienumerable-of-opc-uafx-opcstructfield)<span class="api-meta">static</span> | Defines a structure derived from the Structure data type. |
| [DefineType(OpcNodeId, OpcName, params OpcStructField\[\])](#definetype-opc-uafx-opcnodeid-opc-uafx-opcname-opc-uafx-opcstructfield-array)<span class="api-meta">static</span> | Defines a structure with the identifier specified derived from the Structure data type. |
| [DefineType(OpcNodeId, OpcName, IEnumerable&lt;OpcStructField&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/members#definetype-opc-uafx-opcnodeid-opc-uafx-opcname-system-collections-generic-ienumerable-of-opc-uafx-opcstructfield)<span class="api-meta">static</span> | Defines a structure with the identifier specified derived from the Structure data type. |

**Exceptions (all overloads)**

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

#### DefineType(OpcName, params OpcStructField\[\])

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

Defines a structure derived from the Structure data type.

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

```csharp
public static OpcStruct DefineType(OpcName name, params OpcStructField[] fields)
```

</div>

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

```vbnet
Public Shared Function DefineType(
    name As OpcName,
    ParamArray fields As OpcStructField()) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `name` | [OpcName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcname/) | The name of the structure. |
| `fields` | params [OpcStructField](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstructfield/)[] | The fields of the structure in the order of their encoding. |

**Returns**

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

A new [OpcStruct](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/) which defines the structure.

#### DefineType(OpcName, IEnumerable&lt;OpcStructField&gt;)

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

Defines a structure derived from the Structure data type.

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

```csharp
public static OpcStruct DefineType(
    OpcName name,
    IEnumerable<OpcStructField> fields)
```

</div>

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

```vbnet
Public Shared Function DefineType(
    name As OpcName,
    fields As IEnumerable(Of OpcStructField)) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `name` | [OpcName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcname/) | The name of the structure. |
| `fields` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcStructField](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstructfield/)&gt; | The fields of the structure in the order of their encoding. |

**Returns**

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

A new [OpcStruct](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/) which defines the structure.

#### DefineType(OpcNodeId, OpcName, params OpcStructField\[\])

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

Defines a structure with the identifier specified derived from the Structure data type.

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

```csharp
public static OpcStruct DefineType(
    OpcNodeId id,
    OpcName name,
    params OpcStructField[] fields)
```

</div>

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

```vbnet
Public Shared Function DefineType(
    id As OpcNodeId,
    name As OpcName,
    ParamArray fields As OpcStructField()) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `id` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the structure. |
| `name` | [OpcName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcname/) | The name of the structure. |
| `fields` | params [OpcStructField](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstructfield/)[] | The fields of the structure in the order of their encoding. |

**Returns**

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

A new [OpcStruct](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/) which defines the structure.

#### DefineType(OpcNodeId, OpcName, IEnumerable&lt;OpcStructField&gt;)

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

Defines a structure with the identifier specified derived from the Structure data type.

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

```csharp
public static OpcStruct DefineType(
    OpcNodeId id,
    OpcName name,
    IEnumerable<OpcStructField> fields)
```

</div>

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

```vbnet
Public Shared Function DefineType(
    id As OpcNodeId,
    name As OpcName,
    fields As IEnumerable(Of OpcStructField)) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `id` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The identifier of the structure. |
| `name` | [OpcName](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcname/) | The name of the structure. |
| `fields` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcStructField](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstructfield/)&gt; | The fields of the structure in the order of their encoding. |

**Returns**

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

A new [OpcStruct](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstruct/) which defines the structure.

### GetFields

Returns the fields of the structure.

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

```csharp
public OpcStructField[] GetFields()
```

</div>

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

```vbnet
Public Function GetFields() As OpcStructField()
```

</div>

**Returns**

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

A new array of the fields in the order of their definition.

### GetNames

Returns the names of the fields of the structure.

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

```csharp
public string[] GetNames()
```

</div>

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

```vbnet
Public Function GetNames() As String()
```

</div>

**Returns**

[String](https://learn.microsoft.com/dotnet/api/system.string)[]

The names of the fields in the order of their definition.

### WithEncodingMask

Sets the encoding mask of the structure.

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

```csharp
public OpcStruct WithEncodingMask(OpcEncodingMask encodingMask)
```

</div>

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

```vbnet
Public Function WithEncodingMask(encodingMask As OpcEncodingMask) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `encodingMask` | [OpcEncodingMask](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmask/) | The encoding mask to use. |

**Returns**

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

This structure.

**Exceptions**

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

### WithEncodings

Sets the encodings of the structure.

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

```csharp
public OpcStruct WithEncodings(params OpcEncoding[] encodings)
```

</div>

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

```vbnet
Public Function WithEncodings(
    ParamArray encodings As OpcEncoding()) As OpcStruct
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `encodings` | params [OpcEncoding](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencoding/)[] | The encodings to use. |

**Returns**

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

This structure.

**Exceptions**

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