# OpcMemberSwitch Members

> Reference: Declares the condition under which an optional member exists in dependency of the value of a switch member.

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

## Constructors

### OpcMemberSwitch

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

| Overload | Description |
|---|---|
| [OpcMemberSwitch(int)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#opcmemberswitch-system-int32) | Initializes a new instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class which refers to the `bit` specified. |
| [OpcMemberSwitch(string)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#opcmemberswitch-system-string) | Initializes a new instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class which refers to the switch member using its `name` specified. |
| [OpcMemberSwitch(string, long)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#opcmemberswitch-system-string-system-int64) | Initializes a new instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class which refers to the switch member using its `name` while its value needs to be equals to the `value` specified. |
| [OpcMemberSwitch(string, long, OpcMemberSwitchOperator)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#opcmemberswitch-system-string-system-int64-opc-uafx-opcmemberswitchoperator) | Initializes a new instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class which refers to the switch member using its `name` while its values is compared to the `value` using the `operator` specified. |

#### OpcMemberSwitch(int)

Initializes a new instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class which refers to the `bit` specified. Using this constructor results in a [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) which evaluates to the value true in case there the `bit` referenced is set (= high) in the 'EncodingMask'.

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

```csharp
public OpcMemberSwitch(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 in the 'EncodingMask' which controls the existence of an optional member. The value needs to be between 0 and 63 (inclusive). |

**Exceptions**

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

**Remarks**

This constructor uses the [Bit](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchconditions/#bit) condition for the [Conditions](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#conditions) property.

#### OpcMemberSwitch(string)

Initializes a new instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class which refers to the switch member using its `name` specified. Using this constructor results in a [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) which evaluates to the value true in case there the value of the switch member referenced by the `name` is not equals zero.

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

```csharp
public OpcMemberSwitch(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 of the switch member its value is compared to control the existence of an optional member. |

**Exceptions**

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

**Remarks**

This constructor uses the [Field](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchconditions/#field) condition for the [Conditions](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#conditions) property.

#### OpcMemberSwitch(string, long)

Initializes a new instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class which refers to the switch member using its `name` while its value needs to be equals to the `value` specified. Using this constructor results in a [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) which evaluates to the value true in case there the value of the switch member referenced by the `name` is equals to the `value`.

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

```csharp
public OpcMemberSwitch(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 of the switch member its value is compared to the `value` to control the existence of an optional member. |
| `value` | [Int64](https://learn.microsoft.com/dotnet/api/system.int64) | The value towards the value of the switch member is to be compared using the [Equals](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchoperator/#equals) operator. The value needs to be between [MinValue](https://learn.microsoft.com/dotnet/api/system.uint32.minvalue) and [MaxValue](https://learn.microsoft.com/dotnet/api/system.uint32.maxvalue). |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `name` is equals [Empty](https://learn.microsoft.com/dotnet/api/system.string.empty). |
| [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). |

**Remarks**

This constructor uses the [Field](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchconditions/#field) and [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchconditions/#value) conditions for the [Conditions](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#conditions) property.

#### OpcMemberSwitch(string, long, OpcMemberSwitchOperator)

Initializes a new instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class which refers to the switch member using its `name` while its values is compared to the `value` using the `operator` specified. Using this constructor results in a [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) which evaluates to the value true in case there the comparison of value of the switch member referenced by the `name` using the `operator` and the `value` results to the value true.

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

```csharp
public OpcMemberSwitch(
    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 of the switch member its value is compared to the `value` to control the existence of an optional member. |
| `value` | [Int64](https://learn.microsoft.com/dotnet/api/system.int64) | The value towards the value of the switch member is to be compared using the `operator` specified. The value needs to be between [MinValue](https://learn.microsoft.com/dotnet/api/system.uint32.minvalue) and [MaxValue](https://learn.microsoft.com/dotnet/api/system.uint32.maxvalue). |
| `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 operator to use when comparing the value of the switch member with the `value` specified. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `name` is equals [Empty](https://learn.microsoft.com/dotnet/api/system.string.empty). |
| [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). |

**Remarks**

This constructor uses the [Field](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchconditions/#field), [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchconditions/#value) and [Operator](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchconditions/#operator) conditions for the [Conditions](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#conditions) property.

## Properties

### Bit

Gets the zero-based number of the bit in the 'EncodingMask' which controls the existence of an optional member.

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

A value between 0 and 63 (inclusive) which refers to the bit in the 'EncodingMask' evaluated to control the existence of an optional member or -1 in case there the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) refers to a switch member using its [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#name).

### Conditions

<span class="api-meta">since v2.9</span>

Gets a value which identities in which way the current [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) decides whether a member exists.

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

```csharp
public OpcMemberSwitchConditions Conditions { get; }
```

</div>

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

```vbnet
Public ReadOnly Property Conditions As OpcMemberSwitchConditions
```

</div>

**Property value**

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

A combination of the members defined by the [OpcMemberSwitchConditions](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchconditions/) enumeration.

**Remarks**

The value of this property depends on which constructor of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class has been used. For more details see the documentation of the constructors.

### Name

Gets the name of the switch member its value is compared to control the existence of an optional member.

<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 [string](https://learn.microsoft.com/dotnet/api/system.string) which identifies the member its value is to be evaluated.

### Operator

Gets a value which defines the relational operator to use when comparing the value of a referenced [Bit](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#bit) or the value of a referenced switch member refered to by [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/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**

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

### Value

Gets the value towards the value of the switch member, referenced by the [Bit](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#bit) of the 'EncodingMask' or by the [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#name), is to be compared using the [Operator](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#operator) of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/).

<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**

[Int64](https://learn.microsoft.com/dotnet/api/system.int64)

The value towards the value of the switch member is compared.

## Methods

### Equals

<span class="api-meta">static · since v2.32</span>

Provides a generic named equality [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) evaluating to the `value` specified.

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

```csharp
public static OpcMemberSwitch Equals(long value)
```

</div>

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

```vbnet
Public Shared Function Equals(value As Long) As OpcMemberSwitch
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | [Int64](https://learn.microsoft.com/dotnet/api/system.int64) | The value towards the value of the switch member is to be compared using the [Equals](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitchoperator/#equals) operator. The value needs to be between [MinValue](https://learn.microsoft.com/dotnet/api/system.uint32.minvalue) and [MaxValue](https://learn.microsoft.com/dotnet/api/system.uint32.maxvalue). |

**Returns**

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

A new instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class initialized with the switch member name "Switch" which evaluates to equality of the `value` specified.

**Exceptions**

| Exception | Condition |
|---|---|
| [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). |

### Matches

Evaluates the switch condition against the `value` specified.

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

```csharp
public bool Matches(long value)
```

</div>

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

```vbnet
Public Function Matches(value As Long) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `value` | [Int64](https://learn.microsoft.com/dotnet/api/system.int64) | The value of the 'EncodingMask' or the value of the switch member referenced by the [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#name) to evaluate (the `value` is evaluated on the left using the [Operator](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#operator) against the [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#value) on the right). |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the value of the 'EncodingMask' specified declares the according [Bit](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#bit) equals 'high' or if the `value` of the switch member compares to the [Value](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/members#value) with a result equals true; otherwise the value false.

### ToString

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

Returns a [string](https://learn.microsoft.com/dotnet/api/system.string) representing the information used by the current [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/).

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

```csharp
public override string ToString()
```

</div>

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

```vbnet
Public Overrides Function ToString() As String
```

</div>

**Returns**

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

A [string](https://learn.microsoft.com/dotnet/api/system.string) representing the current [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/).

**Overrides**

[ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)
