Sunday, June 23, 2024 20:27

Table of contents >> Introduction > Representation of True and False values

Representation of True and False values

A few lessons so far dealt with conditional processing, displaying a result when a condition is true, and another when it is false. When working with conditional processing, it is important to understand the representation of True and False values in C#.

C# checks by default a conditional statement if it returns a true value. Many inexperienced programmers write their test conditions as follows:

Since the program checks the default value as being True, you can write you test conditions by simply placing the condition in parenthesis:

When the expression is evaluated as a value different than False, C# executes the instructions that follows immediately after the condition. When it is evaluated as False, C# will simply ignore the instructions that follow after the condition.

The concepts explained in this lesson are also shown visually as part of the following video:

Tags: ,

Leave a Reply

Follow the white rabbit