Chevron Left Icon
Understanding Logic in C#
Lesson 1 of 2
Chevron Right Icon
  1. 1

    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…

  2. 2

    In C#, we can represent Boolean values using the […] data type. Booleans, unlike numbers or strings, only have two values: true and false. To define a variable as a boolean, you define the dat…

  3. 3

    When writing a program, we often need to check if a value is correct or compare two values. Comparison operators allow us to compare values and evaluate their relationship. Rather than evaluating t…

  4. 4

    We can also use operators that use Boolean values as inputs and output. Logical operators, also known as Boolean operators, can be used to create Boolean expressions. Logical operators include: -…

  5. 5

    As we saw in the truth table, a Boolean expression that uses logical operators can be as simple as evaluating two boolean values: […] In this case, we’re saying that […] is equal to the ev…

  6. 6

    Great job! You just learned about logic and boolean values, including: - How to define variables with a […] data type - How to use comparison operators with different data types to return boole…

  1. 1

    We make decisions all the time in our life based on different conditions. Are you going to drink tea or coffee? Study history or biology? Buy a new shirt or save your money? We can program comput…

  2. 2

    Conditional statements are the most commonly used control structures in programming. They rely on the computer being able to reason whether conditions are true or false. The most basic conditiona…

  3. 3

    What if we want another set of instructions to execute if the condition is false? An […] clause can be added to an […] statement to provide code that will only be executed if the […] co…

  4. 4

    What if we want to handle multiple conditions and have a different thing happen each time? Conditional statements can be chained by combining […] and […] statements into […] . After an i…

  5. 5

    Using multiple […] statements can get unwieldy pretty quickly. Imagine writing an […] statement for every possible number of guests. And you invited 20 people. You have to write a lot of re…

  6. 6

    The ternary operator allows for a compact syntax in the case of binary decisions. Like an […] statement, it evaluates a single condition and executes one expression if the condition is true a…

  7. 7

    Great job! You just learned about how to create programs that use control flow. Here’s a few of the things we covered: - Using […] , […] , and […] keywords to write conditional statements…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo