if (5 < 6 && 9 == 9) {
//This is called if 5 Less Than 6 AND 9 is equal to 9.
//The "&&" in the if statement repersents the "and"
}
using System;
namespace DecisionMaking
{
class Program
{
static void Main(string[] args)
{
/* local variable definition */
int a = 10;
/* check the boolean condition using if statement */
if (a < 20)
{
/* if condition is true then print the following */
Console.WriteLine("a is less than " + a); //output: a is less than 20
}
Console.ReadLine();
}
}
}
int a = 5;
int b = 10;
if (b > a) //true
{
b = b - a;
}
bool condition = true;
if(condition)
var t = "The condition its true";
else
var f = "The condition its false";
// We dont need to use the '{' because it's just 1 change
if (title == "User greeting" || "User name")
{
do stuff
}
if (condition)
{
print("Yes");
}
else
{
print("No");
}
int time = 22;
if (time < 10)
{
Console.WriteLine("Good morning.");
}
else if (time < 20)
{
Console.WriteLine("Good day.");
}
else
{
Console.WriteLine("Good evening.");
}
if (title == "User greeting" || "User name") {do stuff}
true && true // = true
true && false // = false
using System;
namespace Conditional
{
class IfStatement
{
public static void Main(string[] args)
{
int number = 2;
if (number < 5)
{
Console.WriteLine("{0} is less than 5", number);
}
Console.WriteLine("This statement is always executed.");
}
}
}
if(x != null)
{
return true
}
//You can't just use:
if (5 == 5 || 6) { ERROR }
//With the || being the OR.
//You have to say:
if (5 == 5 || 6 == 6) { WORKED }
//Hope that helped! :)