# 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]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gabriel-schade-cardoso.gitbook.io/tango/extensions/enum-extensions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
