C# Tutorials - Herong's Tutorial Examples - v3.32, by Herong Yang
"if" Statements
This section describes 'if' statements - logical conditions to determine whether embedded statements should be executed or not.
The most commonly used conditional statement is the "if" statement, which has the following syntax:
if statement: if (logical_expression) { embedded_statements }
When an "if" statement is encountered in the execution flow, the logical expression will be evaluated first. If the resulting value is true, the embedded statements that are enclosed in braces immediately after the logical expression will be executed. If the resulting value is false, those embedded statements will be skipped.
An "if" statement can also have an "else" clause, which will contain a block of embedded statements to be executed only when the logical expression is evaluated to false. Here is the syntax of "if else" statement:
if statement: if (logical_expression) { embedded_statements } else { embedded_statements }
In the "else" clause, we could have another logical condition to separate the execution in two more ways:
if statement: if (logical_expression) { embedded_statements } else if (another_logical_expression) { embedded_statements } else { embedded_statements }
Table of Contents
►Logical Expressions and Conditional Statements
Visual C# 2010 Express Edition
C# Compiler and Intermediate Language
Compiling C# Source Code Files
MSBuild - Microsoft Build Engine
System.Diagnostics.FileVersionInfo Class
WPF - Windows Presentation Foundation