> 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/modules/collection/collect.md).

# Collect

Projects each element of a sequence to an `IEnumerable<TResult>` and flattens the resulting sequences into one collection.

| Parameters                                                                  | Returns               |
| --------------------------------------------------------------------------- | --------------------- |
| <p>Func\<T, IEnumerable\<TResult>> mapping</p><p>IEnumerable\<T> source</p> | IEnumerable\<TResult> |

## Usage

A new collection is created by applying the `mapping` function in each element. After that, the result is flattened.

This function works like the `SelectMany` method.

&#x20;**Creating a new function**&#x20;

```csharp
//IEnumerable<int> source = { 1, 2, 3 }

IEnumerable<int> GenerateNumbers(int value)
{
    for(int index = 1; index <= 3; index++)
        yield return value * 10;
}

IEnumerable<int> result = source.Collect(GenerateNumbers);

//result = = { 10, 20, 30, 20, 40, 60, 30, 60, 90 }
```
