> For the complete documentation index, see [llms.txt](https://gabriel-schade-cardoso.gitbook.io/tango/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gabriel-schade-cardoso.gitbook.io/tango/extensions/enum-extensions.md).

# Enum Extensions

> [`Tango.Linq.EnumExtensions`](https://github.com/gabrielschade/Tango/blob/master/Tango/Tango/Linq/EnumExtensions.cs)

This class contains two different methods to deal with `enum` types as `IEnumerable<T>` collections, where T is equals to the `enum` type.

## Methods

| Name                 | Parameters | Returns         | Description                                                                                            |
| -------------------- | ---------- | --------------- | ------------------------------------------------------------------------------------------------------ |
| AsEnumerable         |            | IEnumerable\<T> | Cast a T enum to an IEnumerable which each element is an enum option.                                  |
| AsEnumerableSkipZero |            | IEnumerable\<T> | Cast a T enum to an IEnumerable which each element is an enum option, except by the zero value option. |

## Usage

You can transform an `enum` type defined by `T` to an `IEnumerable<T>`. Simplily executes the `AsEnumerable` method with `enum` type.

See the code bellow:

```csharp
enum Options
{
  None = 0,
  FirstOption = 1,
  SecondOption = 2,
  ThirdOption = 3
}

IEnumerable<Options> result = EnumExtensions.AsEnumerable<Options>();

// result = [None, FirstOption, SecondOption, ThirdOption]
```

You can ignore the zero value by using `AsEnumerableSkipZero` method, if you need.

```csharp
enum Options
{
  None = 0,
  FirstOption = 1,
  SecondOption = 2,
  ThirdOption = 3
}

IEnumerable<Options> result = EnumExtensions.AsEnumerable<Options>();

// result = [FirstOption, SecondOption, ThirdOption]
```
