Professional Documents
Culture Documents
CIT304 Chapter 6 Y24
CIT304 Chapter 6 Y24
Conditional Statement in C#
Adedoyin I. OYEBADE
sacnet2015@gmail.com
Bowen University,
Iwo, Nigeria
1 Conditional Statement in C#
Comparison Operators
Conditional Statements ”if” and ”if-else”
1 Comparism Operators
• Comparism operators are used to pair integers, floating-point
numbers, characters, strings and other types
• Comparison operators can be used to compare expressions
such as two numbers, two numerical expressions, or a number
and a variable
• The result of the comparison is a Boolean value (true or false).
1 Logical Operators
• Logical (Boolean) operators take Boolean values and return a
Boolean result (true or false).
• The basic Boolean operators are ”AND” (&&), ”OR” (||), ”exclusive
OR” ( ˆ) and logical negation (!).
if (Boolean expression)
{
Body of the conditional statement;
}
if (Boolean expression)
{
Body of the conditional statement;
} else
{
Body of the else statement;
}