4.6.0 (latest) 4.5.0 4.4.0 4.3.0 4.2.0 4.1.0 4.0.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.1 3.4.0 3.3.0 3.2.0 3.1.0 3.0.0 2.5.0 2.4.0 2.3.1

    public sealed class FirestoreEnumNameConverter<T> : IFirestoreConverter<T> where T : struct, Enum

Reference documentation and code samples for the Firestore API class FirestoreEnumNameConverter

<br />

Custom converter which uses enum value names instead of integer values as the Firestore representation.
This converter is not used by default; it must be configured in the same way as any other custom converter.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> FirestoreEnumNameConverter\<T\>

## Implements

[IFirestoreConverter](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Firestore/latest/Google.Cloud.Firestore.IFirestoreConverter-1)

## Inherited Members

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

## Namespace

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

## Assembly

Google.Cloud.Firestore.dll

| ## Type Parameter ||
|---|---|
| **Name** | **Description** |
| `T` | The enum type to convert |

## Remarks


Currently this is always case-sensitive, with no customization of the names used. In future releases
we may introduce further ways to configure this converter, but the default behavior will remain the same.


When the same enum value has multiple names, no guarantee is made about which one is returned, although both
are accepted for conversion back to enum values. You are strongly encouraged not to use multiple names for the
same value.

## Methods

### FromFirestore(object)

    public T FromFirestore(object value)

Converts a value from its Firestore representation.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `https://learn.microsoft.com/dotnet/api/system.object` The value to convert. When called by Google.Cloud.Firestore, this will never be null. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `T` | The converted value. Must not be null. |

### ToFirestore(T)

    public object ToFirestore(T value)

Converts an enum value to its name.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `value` | `T` The value to convert. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.object` | The name of the value. |

**Remarks** If multiple values in the enum map to the same integer, it is undefined which will be returned.
If the value is not a named enum element, an exception is thrown, even if the enum is
decorated with [FlagsAttribute](https://learn.microsoft.com/dotnet/api/system.flagsattribute).

| **Exceptions** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.argumentexception` | The given value is not a named value within the enum. |