# OpcDataTypeEncodingMaskAttribute Members

> Reference: Defines the size of the mask used to encode optional field information of the custom data type represented by the Type on that this attribute is applied.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcDataTypeEncodingMaskAttribute</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 [Attribute](https://learn.microsoft.com/dotnet/api/system.attribute).

## Constructors

### OpcDataTypeEncodingMaskAttribute

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

| Overload | Description |
|---|---|
| [OpcDataTypeEncodingMaskAttribute()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/members#opcdatatypeencodingmaskattribute-noparams) | Initializes a new instance of the [OpcDataTypeEncodingMaskAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/) class using the [OpcEncodingMaskKind](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmaskkind/) value [Auto](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmaskkind/#auto) and the smallest number of bytes required to represent the necessary bit mask to define the existence of optional fields. |
| [OpcDataTypeEncodingMaskAttribute(OpcEncodingMaskKind)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/members#opcdatatypeencodingmaskattribute-opc-uafx-opcencodingmaskkind) | Initializes a new instance of the [OpcDataTypeEncodingMaskAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/) class using the `kind` specified and the smallest number of bytes required to represent the necessary bit mask to define the existence of optional fields. |

#### OpcDataTypeEncodingMaskAttribute()

Initializes a new instance of the [OpcDataTypeEncodingMaskAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/) class using the [OpcEncodingMaskKind](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmaskkind/) value [Auto](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmaskkind/#auto) and the smallest number of bytes required to represent the necessary bit mask to define the existence of optional fields.

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

```csharp
public OpcDataTypeEncodingMaskAttribute()
```

</div>

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

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

</div>

#### OpcDataTypeEncodingMaskAttribute(OpcEncodingMaskKind)

Initializes a new instance of the [OpcDataTypeEncodingMaskAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/) class using the `kind` specified and the smallest number of bytes required to represent the necessary bit mask to define the existence of optional fields.

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

```csharp
public OpcDataTypeEncodingMaskAttribute(OpcEncodingMaskKind kind)
```

</div>

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

```vbnet
Public Sub New(kind As OpcEncodingMaskKind)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `kind` | [OpcEncodingMaskKind](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmaskkind/) | One of the members defined by the [OpcEncodingMaskKind](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmaskkind/) enumeration. |

## Properties

### Kind

Gets the [OpcEncodingMaskKind](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmaskkind/) which is used to determine whether the mask data is controlled by the data type or is to be determined and processed inline while reading or writing the custom data type.

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

```csharp
public OpcEncodingMaskKind Kind { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Kind As OpcEncodingMaskKind
```

</div>

**Property value**

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

One of the members defined by the [OpcEncodingMaskKind](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmaskkind/) enumeration. The default value is [Auto](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmaskkind/#auto).

### Size

Gets or sets the number of bytes used to encode the existence of optional fields in the stream of the custom data type to that this attribute has been applied.

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

```csharp
public int Size { get; set; }
```

</div>

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

```vbnet
Public Property Size As Integer
```

</div>

**Property value**

[Int32](https://learn.microsoft.com/dotnet/api/system.int32)

The number of bytes used to encode the existence of optional fields which can be a value between -1 and 8 (inclusive). In case there -1 is used the number of bytes is determined by the number of optional fields declared in the custom data type. This number defines the number of bits required to mask the existence of an optional field and therefore defines the number of bytes required as well (e.g. 8 bits for 0 to 7 optional fields with [Size](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/members#size) equals 1, 16 bits for 0-15 optional fields with [Size](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/members#size) equals 2 and so).

In case there a value less than -1 (the default value) is specified; -1 is used instead. In case there a value greater than 8 is specified; 8 is used instead.

### SizeInBits

Gets or sets the number of bits to use to encode the existence of optional fields in the stream of the custom data type to that this attribute has been applied.

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

```csharp
public int SizeInBits { get; set; }
```

</div>

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

```vbnet
Public Property SizeInBits As Integer
```

</div>

**Property value**

[Int32](https://learn.microsoft.com/dotnet/api/system.int32)

The number of bits used to encode the existence of optional fields which can be a value between -1 and 64 (inclusive). In case there -1 is used the number of bits is determined by the number of optional fields declared in the custom data type. This number defined the number of bits required to mask the existence of an optional field and therefore defines the value of this property (e.g. 8 bits for 0 to 7 optional fields, 16 bits for 0-15 optional fields and so).

The value of this property defines the multiple of 8 using the value of the [Size](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/members#size) used (if not -1).

In case there a value less than -1 (the default value) is specified; -1 is used instead. In case there a value greater than 64 is specified; 64 is used instead.

## Methods

### GetEncodingMask

Retrieves the [OpcEncodingMask](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmask/) information defined by the [OpcDataTypeEncodingMaskAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/).

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

```csharp
public OpcEncodingMask GetEncodingMask()
```

</div>

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

```vbnet
Public Function GetEncodingMask() As OpcEncodingMask
```

</div>

**Returns**

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

A new [OpcEncodingMask](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcencodingmask/) instance which defines the information required to declare and process the mask used to encode the existence of optional fields in the stream of a custom data type.
