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

    public sealed class EnumDescriptor : DescriptorBase, IDescriptor

Descriptor for an enum type in a .proto file.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [DescriptorBase](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase) \> EnumDescriptor

## Implements

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

## Inherited Members

[DescriptorBase.Index](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_Index) [DescriptorBase.FullName](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_FullName) [DescriptorBase.File](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_File) [DescriptorBase.Declaration](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_Declaration) [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

### ClrType

    public Type ClrType { get; }

The CLR type for this enum. For generated code, this will be a CLR enum type.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.type` |   |

### ContainingType

    public MessageDescriptor ContainingType { get; }

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.MessageDescriptor` | If this is a nested type, get the outer descriptor, otherwise null. |

### CustomOptions

    [Obsolete("CustomOptions are obsolete. Use the GetOptions() method.")]
    public CustomOptions CustomOptions { get; }

The (possibly empty) set of custom options for this enum.

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

### Name

    public override string Name { get; }

The brief name of the descriptor's target.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

**Overrides** [DescriptorBase.Name](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.DescriptorBase#Google_Protobuf_Reflection_DescriptorBase_Name)

### Values

    public IList<EnumValueDescriptor> Values { get; }

| **Property Value** ||
|---|---|
| **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.EnumValueDescriptor` | An unmodifiable list of defined value descriptors for this enum. |

## Methods

### FindValueByName(string)

    public EnumValueDescriptor FindValueByName(string name)

Finds an enum value by name.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `name` | `https://learn.microsoft.com/dotnet/api/system.string` The unqualified name of the value (e.g. "FOO"). |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.EnumValueDescriptor` | The value's descriptor, or null if not found. |

### FindValueByNumber(int)

    public EnumValueDescriptor FindValueByNumber(int number)

Finds an enum value by number. If multiple enum values have the
same number, this returns the first defined value with that number.
If there is no value for the given number, this returns `null`.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `number` | `https://learn.microsoft.com/dotnet/api/system.int32` |

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

### GetOption\<T\>(Extension\<EnumOptions, T\>)

    [Obsolete("GetOption is obsolete. Use the GetOptions() method.")]
    public T GetOption<T>(Extension<EnumOptions, T> extension)

Gets a single value enum option for this descriptor

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `extension` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Extension-2https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.EnumOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` |   |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` |   |

### GetOption\<T\>(RepeatedExtension\<EnumOptions, T\>)

    [Obsolete("GetOption is obsolete. Use the GetOptions() method.")]
    public RepeatedField<T> GetOption<T>(RepeatedExtension<EnumOptions, T> extension)

Gets a repeated value enum option for this descriptor

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `extension` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.RepeatedExtension-2https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.EnumOptions` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Collections.RepeatedField-1` |   |

| **Type Parameter** ||
|---|---|
| **Name** | **Description** |
| `T` |   |

### GetOptions()

    public EnumOptions GetOptions()

The `EnumOptions`, defined in `descriptor.proto`.
If the options message is not present (i.e. there are no options), `null` is returned.
Custom options can be retrieved as extensions of the returned message.
NOTE: A defensive copy is created each time this property is retrieved.

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

### ToProto()

    public EnumDescriptorProto ToProto()

Returns a clone of the underlying [EnumDescriptorProto](https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.EnumDescriptorProto) describing this enum.
Note that a copy is taken every time this method is called, so clients using it frequently
(and not modifying it) may want to cache the returned value.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Reflection.EnumDescriptorProto` | A protobuf representation of this enum descriptor. |