# OpcDataTypeMemberSwitchAttribute Members

> Reference: 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.

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

### OpcDataTypeMemberSwitchAttribute

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

| Overload | Description |
|---|---|
| [OpcDataTypeMemberSwitchAttribute()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-noparams) | Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.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). |
| [OpcDataTypeMemberSwitchAttribute(int)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-system-int32) | Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) class which declares a field or property to be optional while its existence is indicated by the `bit` specified. |
| [OpcDataTypeMemberSwitchAttribute(string)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-system-string) | Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) class which declares a field or property to be optional while its existence is controlled by the value of a preceding field or property which can be identified by the `name` specified while its value needs to be "not equals" to zero. |
| [OpcDataTypeMemberSwitchAttribute(string, long)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-system-string-system-int64) | Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) class which declares a field or property to be optional while its existence is controlled by the value of a preceding field or property which can be identified by the `name` specified while its value needs to be "equals" to the `value` specified. |
| [OpcDataTypeMemberSwitchAttribute(string, long, OpcMemberSwitchOperator)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#opcdatatypememberswitchattribute-system-string-system-int64-opc-uafx-opcmemberswitchoperator) | Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) class which declares a field or property to be optional while its existence is controlled by the value of a preceding field or property which can be identified by the `name` specified while its value is compared to the `value` using the comparison `operator` specified. |

#### OpcDataTypeMemberSwitchAttribute()

Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.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). In case there the bit is set the data of the member is read or written from or to the stream of the data type; otherwise the data member is skipped and the next member is processed.

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

```csharp
public OpcDataTypeMemberSwitchAttribute()
```

</div>

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

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

</div>

#### OpcDataTypeMemberSwitchAttribute(int)

Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) class which declares a field or property to be optional while its existence is indicated by the `bit` specified.

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

```csharp
public OpcDataTypeMemberSwitchAttribute(int bit)
```

</div>

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

```vbnet
Public Sub New(bit As Integer)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `bit` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero based number of the bit which indicates whether the field or property the attribute belongs to exists in the stream of the data type. The bit number specified may not be contiguous and may control multiple fields. In case there the bit is set the data of the member is read or written from or to the stream of the data type; otherwise the data member is skipped and the next member is processed. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `bit` is less than zero or greater than 64. |

#### OpcDataTypeMemberSwitchAttribute(string)

Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) class which declares a field or property to be optional while its existence is controlled by the value of a preceding field or property which can be identified by the `name` specified while its value needs to be "not equals" to zero.

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

```csharp
public OpcDataTypeMemberSwitchAttribute(string name)
```

</div>

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

```vbnet
Public Sub New(name As String)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `name` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The [Name](https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo.name) or [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberattribute/members#name) (if defined) of the preceding member its value needs to be "not equals" to zero to indicate that the member the attribute belongs to exists and the data of the member is read or written from or to the stream of the data type; otherwise the data member is skipped and the next member is processed. |

**Exceptions**

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

#### OpcDataTypeMemberSwitchAttribute(string, long)

Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) class which declares a field or property to be optional while its existence is controlled by the value of a preceding field or property which can be identified by the `name` specified while its value needs to be "equals" to the `value` specified.

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

```csharp
public OpcDataTypeMemberSwitchAttribute(string name, long value)
```

</div>

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

```vbnet
Public Sub New(name As String, value As Long)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `name` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The [Name](https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo.name) or [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberattribute/members#name) (if defined) of the preceding member its value needs to be "equals" to the `value` specified to indicate that the member the attribute belongs to exists and the data of the member is read or written from or to the stream of the data type; otherwise the data member is skipped and the next member is processed. |
| `value` | [Int64](https://learn.microsoft.com/dotnet/api/system.int64) | The [long](https://learn.microsoft.com/dotnet/api/system.int64)-value the value of the member referenced by `name` needs to be equals to, to indicate that the member the attribute belongs to exists. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `name` is an empty string. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `name` is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `value` is less than [MinValue](https://learn.microsoft.com/dotnet/api/system.uint32.minvalue) or greater than [MaxValue](https://learn.microsoft.com/dotnet/api/system.uint32.maxvalue). |

#### OpcDataTypeMemberSwitchAttribute(string, long, OpcMemberSwitchOperator)

Initializes a new instance of the [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) class which declares a field or property to be optional while its existence is controlled by the value of a preceding field or property which can be identified by the `name` specified while its value is compared to the `value` using the comparison `operator` specified.

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

```csharp
public OpcDataTypeMemberSwitchAttribute(
    string name,
    long value,
    OpcMemberSwitchOperator @operator)
```

</div>

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

```vbnet
Public Sub New(
    name As String,
    value As Long,
    [operator] As OpcMemberSwitchOperator)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `name` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The [Name](https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo.name) or [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberattribute/members#name) (if defined) of the preceding member its value is compared to the `value` specified using the comparison `operator` specified to indicate that the member the attribute belongs to exists and the data of the member is read or written from or to the stream of the data type; otherwise the data member is skipped and the next member is processed. |
| `value` | [Int64](https://learn.microsoft.com/dotnet/api/system.int64) | The [long](https://learn.microsoft.com/dotnet/api/system.int64)-value the value of the member referenced by `name` needs fulfill using the comparison `operator` specified, to indicate that the member the attribute belongs to exists. |
| `operator` | [OpcMemberSwitchOperator](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchoperator/) | One of the members defined by the [OpcMemberSwitchOperator](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchoperator/) enumeration which defines the comparison operator to evaluate against the value of the member referenced by `name`. Only in case there the comparison result is equals true, the member this attribute belongs to exists; otherwise the result is equals false it is skipped when reading or writing the data of its data type. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `name` is an empty string. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `name` is a null reference (Nothing in Visual Basic). |
| [ArgumentOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception) | The `value` is less than [MinValue](https://learn.microsoft.com/dotnet/api/system.uint32.minvalue) or greater than [MaxValue](https://learn.microsoft.com/dotnet/api/system.uint32.maxvalue). |

## Properties

### 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.

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

```csharp
public int Bit { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Bit As Integer
```

</div>

**Property value**

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

The zero based number of the bit, which may not be contiguous and may control multiple fields. The default value is -1. In case there the value of the [Bit](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#bit) property is equals -1 and the value of the [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#value) property is a null reference (Nothing in Visual Basic) this [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) refers to a [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) which is determined by the next free bit in sequence of all bits in the encoding mask used bits.

### 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.

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

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

</div>

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

```vbnet
Public ReadOnly Property Name As String
```

</div>

**Property value**

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

The [Name](https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo.name) or [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberattribute/members#name) (if defined) of the preceding member or a null reference (Nothing in Visual Basic) in case there this [OpcDataTypeMemberSwitchAttribute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/) refers to a [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) which is determined by the value of the [Bit](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#bit) property.

### 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).

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

```csharp
public OpcMemberSwitchOperator? Operator { get; }
```

</div>

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

```vbnet
Public ReadOnly Property [Operator] As OpcMemberSwitchOperator?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[OpcMemberSwitchOperator](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchoperator/)&gt;

One of the members defined by the [OpcMemberSwitchOperator](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchoperator/) enumeration which defines the comparison operator to evaluate or a null reference (Nothing in Visual Basic) if a default operator is to be used. The default operator used is determined by the value of the [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#value) property. If [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#value) is a null reference (Nothing in Visual Basic) [NotEqual](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchoperator/#notequal) is used; otherwise [Equals](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchoperator/#equals).

### 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.

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

```csharp
public long? Value { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Value As Long?
```

</div>

**Property value**

[Nullable](https://learn.microsoft.com/dotnet/api/system.nullable-1)&lt;[Int64](https://learn.microsoft.com/dotnet/api/system.int64)&gt;

The [long](https://learn.microsoft.com/dotnet/api/system.int64)-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 or a null reference (Nothing in Visual Basic) if either the [Bit](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#bit) property is set or a comparison against zero needs to be evaluated by default using the [NotEqual](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchoperator/#notequal) operator.

## Methods

### GetSwitch

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

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

```csharp
public OpcMemberSwitch GetSwitch(int bit)
```

</div>

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

```vbnet
Public Function GetSwitch(bit As Integer) As OpcMemberSwitch
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `bit` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | The zero based number of the next free bit in sequence of all bits in the encoding mask used bits if [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#name) is a null reference (Nothing in Visual Basic) and [Bit](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypememberswitchattribute/members#bit) is equals to -1. |

**Returns**

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

A new [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) instance which provides the information required to switch the member the attribute belongs to.
