# Swap

Troca o tipo do `Either<TLeft, TRight>` alterando os valores `Right` e `Left`.

| Parâmetros                    | Retorno                |
| ----------------------------- | ---------------------- |
| Either\<TLeft, TRight> either | Either\<TRight, TLeft> |

## Como usar

Este método deve ser utilizado quando for necessário alterar a ordem entre os valores TLeft e TRight.

&#x20;**Quando o valor Either está no estado IsRight**&#x20;

```csharp
Either<string, int> either = 42;
Either<int, string> eitherResult = either.Swap();

//eitherResult.IsLeft = true
//eitherResult.Left = 42
```

&#x20;**Quando o valor Either está no estado IsLeft**&#x20;

```csharp
Either<string, int> either = "Hello";
Either<int, string> eitherResult = either.Swap();

//eitherResult.IsRight = true
//eitherResult.Right = "Hello"
```


---

# 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-br/modulos/either/swap.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.
