What is a Boolean?

You are currently viewing What is a Boolean?

Overview

A Boolean is a binary data type containing either the value of True or False.

A real-world example of a Boolean is a light switch, where there are only two possible settings, on or off.

By default, the Boolean data type is set to false.

Booleans are great for control flow by being paired with conditional statements enabling your automation to make decisions based on the results of the Boolean value, therefore providing a better control over the flow of your automation.

Contents

What can you do with Booleans?

Below or some great examples of the use of Booleans:

  • Deciding factor for If Statements
  • Assign Returns for Failure/Success
  • Enable/Disable workflow components

Commonly Used Methods

Below are some commonly used methods for Booleans. Methods are actions that objects (i.e. Booleans) can perform. To learn more about methods, click here.

For all examples below, we will be using the following Boolean variable, boolVar, which has been assigned as True.

CompareTo(Boolean) - Compares 2 Booleans. Returns 1 if they match or 0 if not

Example Method Example Return Return Type
True.CompareTo(False)
0
Integer (Int32)
True.CompareTo(True)
1
Integer (Int32)
boolVar.CompareTo(False)
0
Integer (Int32)

Equals(Boolean) - Determines if 2 Booleans are Equal

Example Method Example Return Return Type
True.Equals(False)
False
Boolean
True.Equals(True)
True
Boolean
boolVar.Equals(True)
True
Boolean

ToString - Converts a Boolean into a String

Example Method Example Return Return Type
True.ToString
"True"
String
False.ToString
"False"
String
boolVar.ToString
"True"
String

Parse(String) - Converts a string to a boolean

Example Method Example Return Return Type
boolVar.Parse("True")
True
Boolean
boolVar.Parse("False")
False
Boolean

GetType - Returns the data type

Example Method Example Return Return Type
boolVar.GetType
System.Boolean
Type