Related Articles

Back to Latest Articles

C# Basics – Conditional Statements – Part 5

Let's have a look at some of the logic operators in C# programming language.

Andraz Krzisnik
C# Basics – Conditional Statements...

Conditional Statements

There is a data type for logic operations, called bool. Possible values that this kind of variable can hold are true and false.

Let’s take a look at logic operators:

  • && – AND
  • || – OR
  • ! – NOT

Comparative Operations

With comparative operators we compare two values. And they always return a bool value, true or false, that is.

If Statement

We use if statement when we want to execute some code when conditions of this if statements, are met.

If-Else Statement

We use if else statement when we want something to happen even if conditions of if statement aren’t met.

Nested If Statements

A nested if statement is an if statement within another if statement. We can also add more if statements that would execute perhaps some different code if there are more than one if statements paired with else.

Download Examples Next Chapter
Show Comments (0)


Related Articles

C# Tutorial

C# Tutorial: How To Convert a Color Image To Grayscale

Grayscale images are basically black and white images. These images are good for programming, since their pixels hold only intensity values or in other words, shades of gray, they...

Posted on by Andraz Krzisnik
C# Basics

C# Basics – Variables and Data Types – Part 4

Variables and Data Types Software works with data that’s stored in the memory. All this data, to be usable, needs to be stored in some defined space. We name these spaces...

Posted on by Andraz Krzisnik