Conditionals in C#
C# uses Boolean variables to evaluate conditions.
The Boolean values true and false are returned when an expression is compared or evaluated.
For example:
int x= 15;
bool b = x== 15;
if (b)
{
Console.WriteLine("It's true!");
}
/* if -else and between statement */
if (x == y)
{
/*x and y are equal, let's do something cool*/
}
/* we can also add an else statement after an if, to do something if the condition is not true */
if (x== y)
{
/*We already know this part*/
}
else
{
/*x and y are not equal...*/
}
C# uses Boolean variables to evaluate conditions.
The Boolean values true and false are returned when an expression is compared or evaluated.
For example:
int x= 15;
bool b = x== 15;
if (b)
{
Console.WriteLine("It's true!");
}
/* if -else and between statement */
if (x == y)
{
/*x and y are equal, let's do something cool*/
}
/* we can also add an else statement after an if, to do something if the condition is not true */
if (x== y)
{
/*We already know this part*/
}
else
{
/*x and y are not equal...*/
}