mirror of
https://github.com/Stone-Red-Code/Stone_Red-C-Sharp-Utilities.git
synced 2026-09-04 09:06:31 +02:00
Created BoolExtentions (markdown)
+101
@@ -0,0 +1,101 @@
|
||||
### Stone_Red_Utilities.BoolExtentions
|
||||
|
||||
#### Methods
|
||||
|
||||
* OneWayTrue
|
||||
* Description: Sets value to true if input is true. If input is false the value will not change.
|
||||
* Parameters: `this ref bool bol`, `bool input`
|
||||
* Example usage:
|
||||
|
||||
```cs
|
||||
bool bol = false;
|
||||
|
||||
bol.OneWayTrue(false);
|
||||
Console.WriteLine(bol);
|
||||
|
||||
bol.OneWayTrue(true);
|
||||
Console.WriteLine(bol);
|
||||
|
||||
bol.OneWayTrue(false);
|
||||
Console.WriteLine(bol);
|
||||
```
|
||||
|
||||
* Output:
|
||||
|
||||
```text
|
||||
False
|
||||
True
|
||||
True
|
||||
```
|
||||
|
||||
* OneWayFalse
|
||||
* Description: Sets value to false if input is false. If input is true the value will not change.
|
||||
* Parameters: `this ref bool bol`, `bool input`
|
||||
* Example usage:
|
||||
|
||||
```cs
|
||||
bool bol = true;
|
||||
|
||||
bol.OneWayFalse(true);
|
||||
Console.WriteLine(bol);
|
||||
|
||||
bol.OneWayFalse(false);
|
||||
Console.WriteLine(bol);
|
||||
|
||||
bol.OneWayFalse(true);
|
||||
Console.WriteLine(bol);
|
||||
```
|
||||
|
||||
* Output:
|
||||
|
||||
```text
|
||||
True
|
||||
False
|
||||
False
|
||||
```
|
||||
|
||||
* ToInt
|
||||
* Description: Converts bool to int.
|
||||
* Parameters: `this bool bol`
|
||||
* Example usage:
|
||||
|
||||
```cs
|
||||
bool bol1 = false;
|
||||
bool bol2 = true;
|
||||
|
||||
int i = bol1.ToInt();
|
||||
int j = bol2.ToInt();
|
||||
|
||||
Console.WriteLine(i);
|
||||
Console.WriteLine(j);
|
||||
```
|
||||
|
||||
* Output:
|
||||
|
||||
```text
|
||||
0
|
||||
1
|
||||
```
|
||||
|
||||
* FromInt
|
||||
* Description: Converts int to bool.
|
||||
* Parameters: `this ref bool bol`, `int input`
|
||||
* Example usage:
|
||||
|
||||
```cs
|
||||
bool bol1;
|
||||
bool bol2;
|
||||
|
||||
bol1.FromInt(0);
|
||||
bol2.FromInt(1);
|
||||
|
||||
Console.WriteLine(bol1);
|
||||
Console.WriteLine(bol2);
|
||||
```
|
||||
|
||||
* Output:
|
||||
|
||||
```text
|
||||
false
|
||||
true
|
||||
```
|
||||
Reference in New Issue
Block a user