# Interface IFieldAccessor (3.27.1)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [3.27.1 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.IFieldAccessor)
- [3.23.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.23.0/Google.Protobuf.Reflection.IFieldAccessor)
- [3.15.8](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.15.8/Google.Protobuf.Reflection.IFieldAccessor)

    public interface IFieldAccessor

Allows fields to be reflectively accessed.

## Namespace

[Google.Protobuf.Reflection](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection)

## Assembly

Google.Protobuf.dll

## Properties

### Descriptor

    FieldDescriptor Descriptor { get; }

Returns the descriptor associated with this field.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.FieldDescriptor` |   |

## Methods

### Clear(IMessage)

    void Clear(IMessage message)

Clears the field in the specified message. (For repeated fields,
this clears the list.)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `message` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage` |

### GetValue(IMessage)

    object GetValue(IMessage message)

Fetches the field value. For repeated values, this will be an
[IList](https://learn.microsoft.com/dotnet/api/system.collections.ilist) implementation. For map values, this will be an
[IDictionary](https://learn.microsoft.com/dotnet/api/system.collections.idictionary) implementation.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `message` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.object` |   |

### HasValue(IMessage)

    bool HasValue(IMessage message)

Indicates whether the field in the specified message is set.
For proto3 fields that aren't explicitly optional, this throws an [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `message` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### SetValue(IMessage, object)

    void SetValue(IMessage message, object value)

Mutator for single "simple" fields only.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `message` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage` |
| `value` | `https://learn.microsoft.com/dotnet/api/system.object` |

**Remarks** Repeated fields are mutated by fetching the value and manipulating it as a list.
Map fields are mutated by fetching the value and manipulating it as a dictionary.

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.invalidoperationexception` | The field is not a "simple" field. |