> 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/forall2.md).

# ForAll2

Tests if all corresponding elements of the collection satisfy the given `predicate` pairwise.

If any application returns `false` then the overall result is `false` and no further elements are tested. Otherwise, `true` is returned.

> &#x20;**WARNING**&#x20;
>
> This function causes [`IEnumerable<T>`](https://msdn.microsoft.com/pt-br/library/9eekhta0%28v=vs.110%29.aspx) evaluation.

| Parameters                                                                                      | Returns |
| ----------------------------------------------------------------------------------------------- | ------- |
| <p>Func\<T, T2, bool> predicate</p><p>IEnumerable\<T> source</p><p>IEnumerable\<T2> source2</p> | bool    |

## Usage

&#x20;**Verifying that all values in both collections are even numbers**&#x20;

```csharp
//IEnumerable<int> source =  { 2, 4, 6, 8, 10 }
//IEnumerable<int> source2 = { 4, 2 }

bool result = 
    source.ForAll2(
        source2, 
        (element1, element2) => element1 % 2 == 0
                             && element2 % 2 == 0);

//result = true
```

```csharp
//IEnumerable<int> source =  { 2, 4, 6, 8, 10 }
//IEnumerable<int> source2 = { 4, 2, 10, 12, 16 }

bool result = 
    source.ForAll2(
        source2, 
        (element1, element2) => element1 % 2 == 0
                             && element2 % 2 == 0);

//result = true
```

&#x20;**Creating an true result even when one of the collections contains an odd number**&#x20;

It is necessary to be careful, different sized collections can create situations like this one:

```csharp
//IEnumerable<int> source =  { 2, 4, 6, 8, 10 }
//IEnumerable<int> source2 = { 4, 2, 10, 12, 16, 1 }

bool result = 
    source.ForAll2(
        source2, 
        (element1, element2) => element1 % 2 == 0
                             && element2 % 2 == 0);

//result = true
```

The result was `true` because of the loop runs only until the smallest collection length, therefore, the last element of `source2` never was checked.
