Computers are constantly checking the state of something. Is this program running or not? Does this variable exist or not? Is this value equal to that value?

These yes or no questions demonstrate that a number of binaries —a relationship between two entities—exist. Computer programs essentially function off of binaries: true and false, yes and no, ones and zeroes, on and off.

Distinguishing between binaries is the foundation of Boolean logic. Boolean logic is based on the idea that all values are either true or false. Logic is important to computer science because it is an early attempt at translating the human capacity for reason to computers. If a computer can use logic to reason about certain situations, it can use that rationale to make decisions.

In this lesson, we’ll explore how Boolean logic works in C# and show you how you can begin to implement boolean data types and expressions in your own programs.


Programmers first were able to illustrate the idea of binary logic through turning on and off electric circuits, where on equaled true and off equaled false. In fact, the relationship between electricity and logic is the basis for digitization - how we store information with electrical circuits!

Flip the switch to see the scene change from day to night and watch the lights turn on and off. Notice how the variable LightsOn stays the same, but its value changes from true to false.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?