# Class MessageDescriptor.FieldCollection (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.MessageDescriptor.FieldCollection)
- [3.23.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.23.0/Google.Protobuf.Reflection.MessageDescriptor.FieldCollection)
- [3.15.8](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/3.15.8/Google.Protobuf.Reflection.MessageDescriptor.FieldCollection)

    public sealed class MessageDescriptor.FieldCollection

A collection to simplify retrieving the field accessor for a particular field.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> MessageDescriptor.FieldCollection

## Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

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

## Assembly

Google.Protobuf.dll

## Properties

### this\[int\]

    public FieldDescriptor this[int number] { get; }

Retrieves the descriptor for the field with the given number.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `number` | `https://learn.microsoft.com/dotnet/api/system.int32` Number of the field to retrieve the descriptor for |

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.FieldDescriptor` | The accessor for the given field |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.keynotfoundexception` | The message descriptor does not contain a field with the given number |

### this\[string\]

    public FieldDescriptor this[string name] { get; }

Retrieves the descriptor for the field with the given name.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` Name of the field to retrieve the descriptor for |

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.FieldDescriptor` | The descriptor for the given field |

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.keynotfoundexception` | The message descriptor does not contain a field with the given name |

## Methods

### InDeclarationOrder()

    public IList<FieldDescriptor> InDeclarationOrder()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.FieldDescriptor` | Returns the fields in the message as an immutable list, in the order in which they are declared in the source .proto file. |

### InFieldNumberOrder()

    public IList<FieldDescriptor> InFieldNumberOrder()

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.FieldDescriptor` | Returns the fields in the message as an immutable list, in ascending field number order. Field numbers need not be contiguous, so there is no direct mapping from the index in the list to the field number; to retrieve a field by field number, it is better to use the [MessageDescriptor.FieldCollection](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.MessageDescriptor.FieldCollection) indexer. |