# OpcDataTypeMemberSwitchAttribute Class

<span class="api-meta">since v2.8</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">OpcDataTypeMemberSwitchAttribute Members</a></dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

Declares a field or property of a custom data type, to that the member belongs on that this attribute is applied, with conditional existence of the member within the stream of its custom data type. Use this attribute to explicitly declare a field or property as optional. Its existence within the stream of its custom data type is declared either using a bit within the encoding mask of the whole data type (see [OpcDataTypeEncodingMaskAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeencodingmaskattribute/)) using the constructors [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-noparams) and [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-system-int32) or using the value of a preceding member using the constructors [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-system-string), [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-system-string-system-int64) or [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-system-string-system-int64-opc-uafx-opcmemberswitchoperator).

## Syntax

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

```csharp
public class OpcDataTypeMemberSwitchAttribute : Attribute
```

</div>

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

```vbnet
<AttributeUsage(AttributeTargets.Property Or AttributeTargets.Field, AllowMultiple:=False, Inherited:=False)>
Public Class OpcDataTypeMemberSwitchAttribute
    Inherits Attribute
```

</div>

## Inheritance

[Object](https://learn.microsoft.com/dotnet/api/system.object) → [Attribute](https://learn.microsoft.com/dotnet/api/system.attribute) → **OpcDataTypeMemberSwitchAttribute**

## Constructors

| Name | Description |
|---|---|
| [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute)<span class="api-meta">5 overloads</span> | Initializes a new instance of the OpcDataTypeMemberSwitchAttribute class which declares a field or property to be optional while its existence is indicated by a single bit (the next free bit in sequence of all bits in the encoding mask used bits). |

## Properties

| Name | Description |
|---|---|
| [Bit](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#bit) | Gets the number of the bit which indiciates whether the field or property the attribute belongs to exists in the stream of the data type. |
| [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#name) | Gets the name of the preceding member its value is to be evaluated to indicate that the member the attribute belongs exists in the stream of the data type. |
| [Operator](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#operator) | Gets a value which identifies the comparison method to use to evaluate the value of member referenced by [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#name). |
| [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#value) | Gets the value the value of the member referenced by [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#name) is compared to. |

## Methods

| Name | Description |
|---|---|
| [GetSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#getswitch) | Retrieves the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) defined by the OpcDataTypeMemberSwitchAttribute using the `bit` specified. |

Inherits members from [Attribute](https://learn.microsoft.com/dotnet/api/system.attribute).

## Applies to

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