Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

BoolExtentions

Stone_Red edited this page May 10, 2021 · 3 revisions

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:

      bool bol = false;
      
      bol.OneWayTrue(false);
      Console.WriteLine(bol);
      
      bol.OneWayTrue(true);
      Console.WriteLine(bol);
      
      bol.OneWayTrue(false);
      Console.WriteLine(bol);
    • Output:

      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:

      bool bol = true;
      
      bol.OneWayFalse(true);
      Console.WriteLine(bol);
      
      bol.OneWayFalse(false);
      Console.WriteLine(bol);
      
      bol.OneWayFalse(true);
      Console.WriteLine(bol);
    • Output:

      True
      False
      False
      
  • ToInt

    • Description: Converts bool to int.

    • Parameters: this bool bol

    • Example usage:

      bool bol1 = false;
      bool bol2 = true;
      
      int i = bol1.ToInt();
      int j = bol2.ToInt();
      
      Console.WriteLine(i);
      Console.WriteLine(j);
    • Output:

      0
      1
      
  • FromInt

    • Description: Converts int to bool.

    • Parameters: this ref bool bol, int input

    • Example usage:

      bool bol1;
      bool bol2;
      
      bol1.FromInt(0);
      bol2.FromInt(1);
      
      Console.WriteLine(bol1);
      Console.WriteLine(bol2);
    • Output:

      false
      true