# OpcDataFieldInfo Members

> Reference: Provides metadata of a field declared by a data type.

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

## Properties

### CustomAttributes

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

Gets an array of custom attributes associated with this field.

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

```csharp
public virtual string[] CustomAttributes { get; }
```

</div>

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

```vbnet
Public Overridable ReadOnly Property CustomAttributes As String()
```

</div>

**Property value**

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

An array of [string](https://learn.microsoft.com/dotnet/api/system.string) values used by the author of this field.

**Remarks**

Applications are not be required to understand these attributes in order to interpret an encoded field value.

### DeclaringType

Gets the type that declares the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

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

```csharp
public OpcDataTypeInfo DeclaringType { get; }
```

</div>

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

```vbnet
Public ReadOnly Property DeclaringType As OpcDataTypeInfo
```

</div>

**Property value**

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

An instance of the [OpcDataTypeInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeinfo/) which declares the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

### Documentation

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

Gets any semantic information that would help a human to understand what is contained in the field.

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

```csharp
public virtual string Documentation { get; }
```

</div>

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

```vbnet
Public Overridable ReadOnly Property Documentation As String
```

</div>

**Property value**

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

A human readable text that describes what is contained in the field and that would help a human to understand what the field represented.

### FieldType

Gets the type of value this field provides.

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

```csharp
public OpcDataTypeInfo FieldType { get; }
```

</div>

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

```vbnet
Public ReadOnly Property FieldType As OpcDataTypeInfo
```

</div>

**Property value**

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

The [OpcDataTypeInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeinfo/) representing the type of value this field provides.

### IsOptional

Gets a value indicating whether the current field might not necessarily exist in the object defined by the [DeclaringType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#declaringtype).

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

```csharp
public bool IsOptional { get; }
```

</div>

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

```vbnet
Public ReadOnly Property IsOptional As Boolean
```

</div>

**Property value**

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

The value true if the field might not always exists; otherwise the value false. Additionally see the [Switch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#switch) property.

**Implements**

[IsOptional](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatafieldinfo/members#isoptional)

### Length

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

Gets the length of the field expressed either explicit or implicit using a different [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

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

```csharp
public virtual OpcMemberLength Length { get; }
```

</div>

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

```vbnet
Public Overridable ReadOnly Property Length As OpcMemberLength
```

</div>

**Property value**

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

An instance of the [OpcMemberLength](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberlength/) class with the explicit length of the field or the reference to the [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/) its value expresses the length of the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

**Implements**

[Length](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatafieldinfo/members#length)

### LengthField

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

Gets the [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/) used to define the length of the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

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

```csharp
public virtual OpcDataFieldInfo LengthField { get; }
```

</div>

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

```vbnet
Public Overridable ReadOnly Property LengthField As OpcDataFieldInfo
```

</div>

**Property value**

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

An instance of the [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/) class its value expresses the length of the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/) or a null reference (Nothing in Visual Basic) if the [Length](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#length) does not refer to a different [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/) used to express the length of the field.

### Name

Gets the name of the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

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

A [string](https://learn.microsoft.com/dotnet/api/system.string) containing the name of this field.

**Implements**

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

### ReflectedType

Gets the type that was used to obtain this instance of [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

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

```csharp
public OpcDataTypeInfo ReflectedType { get; }
```

</div>

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

```vbnet
Public ReadOnly Property ReflectedType As OpcDataTypeInfo
```

</div>

**Property value**

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

An instance of the [OpcDataTypeInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeinfo/) used to obtain this instance.

### Switch

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

Gets the switch condition which applies to the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

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

```csharp
public virtual OpcMemberSwitch Switch { get; }
```

</div>

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

```vbnet
Public Overridable ReadOnly Property Switch As OpcMemberSwitch
```

</div>

**Property value**

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

An instance of the [OpcMemberSwitch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmemberswitch/) class which defines the conditions to fulfill so that the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/) exists in an instance.

**Implements**

[Switch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatafieldinfo/members#switch)

### SwitchField

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

Gets the [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/) used to evaluate the [Switch](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#switch) condition which applies to the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

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

```csharp
public virtual OpcDataFieldInfo SwitchField { get; }
```

</div>

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

```vbnet
Public Overridable ReadOnly Property SwitchField As OpcDataFieldInfo
```

</div>

**Property value**

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

An instance of the [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/) class its value is to be evaluated to determine whether the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/) exists in an instance.

## Methods

### GetLength

<span class="api-meta">virtual · since v2.58</span>

Gets the maximum length of the specified dimension of the field as the definition of its data type states it.

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

```csharp
public virtual int GetLength(int dimension)
```

</div>

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

```vbnet
Public Overridable Function GetLength(dimension As Integer) As Integer
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `dimension` | [Int32](https://learn.microsoft.com/dotnet/api/system.int32) | A zero-based dimension of the [FieldType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#fieldtype) whose length is to be determined; its number of dimensions is stated by [GetArrayRank](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypeinfo/members#getarrayrank). |

**Returns**

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

The maximum length of the `dimension`, or 0 if it is not known. A value may hold less.

**Exceptions**

| Exception | Condition |
|---|---|
| [IndexOutOfRangeException](https://learn.microsoft.com/dotnet/api/system.indexoutofrangeexception) | The [FieldType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#fieldtype) is not an array, or the `dimension` is less than zero or equal to or greater than its number of dimensions. |

**Remarks**

Of a field of one dimension, the length is the one stated by [Length](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#length) as well, if that is not given by a different field.

### GetValue

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

Gets the value of the field supported by the given object `instance`.

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

```csharp
public virtual object GetValue(object instance)
```

</div>

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

```vbnet
Public Overridable Function GetValue(instance As Object) As Object
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `instance` | [Object](https://learn.microsoft.com/dotnet/api/system.object) | The [object](https://learn.microsoft.com/dotnet/api/system.object) whose field value will be returned. |

**Returns**

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

An object containing the value of the field reflected by this instance.

**Implements**

[GetValue](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatafieldinfo/members#getvalue)

**Remarks**

This method throws a [NotSupportedException](https://learn.microsoft.com/dotnet/api/system.notsupportedexception) and have to be overridden in a derived class.

### SetValue

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

Sets the value of the field supported by the given object `instance`.

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

```csharp
public virtual void SetValue(object instance, object value)
```

</div>

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

```vbnet
Public Overridable Sub SetValue(instance As Object, value As Object)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `instance` | [Object](https://learn.microsoft.com/dotnet/api/system.object) | The [object](https://learn.microsoft.com/dotnet/api/system.object) whose field value will be set. |
| `value` | [Object](https://learn.microsoft.com/dotnet/api/system.object) | The value to assign to the field. |

**Implements**

[SetValue](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatafieldinfo/members#setvalue)

**Remarks**

This method throws a [NotSupportedException](https://learn.microsoft.com/dotnet/api/system.notsupportedexception) and have to be overridden in a derived class.

### ToString

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

Returns a [string](https://learn.microsoft.com/dotnet/api/system.string) representing the [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#name) and [FieldType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#fieldtype) of the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

<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 [Name](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#name) and the [FieldType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/members#fieldtype) of the current [OpcDataFieldInfo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatafieldinfo/).

**Overrides**

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