# Operations with Booleans

> [`Tango.CommonOperations.BoolOperations`](https://github.com/gabrielschade/Tango/blob/master/Tango/Tango/Operations/BoolOperations.cs)

This *static* class contains methods and properties to expose common operations to work with `bool` types.

All members bellow returns the corresponding functions as delegates.

## Properties

| Name | Type                    | Description                                                           |
| ---- | ----------------------- | --------------------------------------------------------------------- |
| Not  | Func\<bool, bool>       | Function to represents the operator !.                                |
| And  | Func\<bool, bool, bool> | Function to represents the and (&&) operation between two booleans.   |
| Or   | Func\<bool, bool, bool> | Function to represents the or (\|\|) operation between two booleans.. |

## Methods

| Name    | Parameters | Returns           | Description                                                                                                               |
| ------- | ---------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------- |
| AndWith | bool value | Func\<bool, bool> | Function to represents the and (&&) operation between two booleans. Applying the first boolean with Partial Application.  |
| OrWith  | bool value | Func\<bool, bool> | Function to represents the or (\|\|) operation between two booleans. Applying the first boolean with Partial Application. |

## Usage

The properties returns a delegate, so, it's possible to use it as a method.

&#x20;**Not**

```csharp
bool value = true;
bool result = BooleanOperations.Not(value);

//result= false
```

&#x20;**Or**

```csharp
bool value = true;
bool value2 = false;
bool result= BooleanOperations.Or(value, value2);

//result = true
```

&#x20;**And**

```csharp
bool value = true;
bool value2 = false;
bool result= BooleanOperations.And(value, value2);

//result = false
```

For methods you can use a little different sintax. It's necessary because these methods uses the property methods combined with Partial Application.

Because of that, you need to execute the method with the first parameter to creates a new single parameter function that perform the operation.

&#x20;**OrWith**

```csharp
bool value = true;
bool value2 = false;
Func<bool,bool> orWithPartial = BooleanOperations.OrWith(value);
bool result = orWithPartial(value2);
//result = true
```

You can also use it as a chainable operation:

```csharp
bool value = true;
bool value2 = false;
bool result = BooleanOperations.OrWith(value)(value2);

//result = true
```

&#x20;**AndWith**

```csharp
bool value = true;
bool value2 = false;
Func<bool,bool> andWithPartial = BooleanOperations.AndWith(value);
bool result = andWithPartial(value2);

//result = false
```

You can also use it as a chainable operation:

```csharp
bool value = true;
bool value2 = false;
bool result = BooleanOperations.AndWith(value)(value2);

//result = false
```


---

# 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/operations/bool.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.
