Zebra0.com

csharp booleanC# Windows Forms Programming

C# Windows Forms Programming

Learn C# (C sharp) in FREE step-by-step lessons.

Boolean Expressions in C#

A Boolean expression is one that can be evaluated as true or false.
A Boolean expression can use relational operators such as < for less than, > for greater than, == for equal, != for not equat and the logical operators && (and) and || (or).
In this lesson we will use the If and optional else statements to decide which statements to execute.

Please study the material at each of the links below.

  1. Microsoft Reference: Boolean expressions Microsoft Reference: Boolean expressions: C# if/else, conditional operators, OR ||, AND &&, switch/case

  2. Boolean Expressions: A Boolean expression is one that can be evaluated to true or false

  3. if Statements: An if statement executes a group of statements only if certain conditions are true

  4. Getting Numbers from Text Box: Numeric values in a text box must be parsed.

  5. A buffet restaurant part 1: Adding radio buttons A buffet restaurant part 1: Adding radio buttons: A restaurant charges different prices for breakfast, lunch and dinner, dicounts.
    /csharp/videos/csharp-buffet1.mp4
  6. A buffet restaurant part 2: Adding code for radio buttons and check boxes A buffet restaurant part 2: Adding code for radio buttons and check boxes: Radio buttons and check boxes have a Boolean property checked
    /csharp/videos/csharp-buffet2.mp4
  7. Rats in a maze Rats in a maze: A few problems to solve using && and ||
    /videos/mousemaze.mp4
  8. Left or Right?: On mouse move determine if the mouse is on left or right of form

  9. Top or bottom?: On mouse move determine if the mouse is on top or bottom of form

  10. Adding the Mouse Move Event Adding the Mouse Move Event: Shows the X and Y positions when the mouse moves on the form
    /csharp/videos/csharp-mousemove.mp4
  11. Scrolling Scrolling: Scrolls a label across the form on the Timer event
    /csharp/videos/csharp-scrolling.mp4
  12. Letter Grade Letter Grade: Nested if/else to find letter grade
    /csharp/videos/csharp-nestedifelse.mp4
  13. BMI: Body Mass Index BMI: Body Mass Index: Nested if/else to find BMI Risk
    /csharp/videos/csharp-bmiRisk.mp4
  14. The conditional operator: ?: The ? can be used for very simple Boolean expressions in place of if/else code

  15. AND && And OR ||: && means AND, || means OR

  16. Drill on Boolean Drill on Boolean: Drill to test your understanding

  17. Middle or Side: Determine if mouse is on the side or middle

  18. Boolean Variables and Properties: Boolean values do not need to be compared to anything

  19. switch/case switch/case: switch/case to show season
    /csharp/videos/csharp-season.mp4
GlossaryGlossary for boolean lesson
Full Glossary