c# multiple if statements code example
Example 1: multiple if statements c#
if((a == 0 || b == 0) && (x == 0 || y == 0))
{
}
Example 2: nested if statement example in c#
class Program{
static void Main(string[] args){
Console.WriteLine("Enter a any number between 1 to 10");
int num1 = Convert.ToInt16(Console.ReadLine());
if (num1 > 100){
Console.WriteLine("Wrong number, {0}", num1);
}else{
if (num1 == 9){
Console.WriteLine("Jackpot number, {0}", num1);
}else{
Console.WriteLine("Your number, {0}", num1);
}
}
}
}
Example 3: c# if statement with 2 conditions
if (checkbox.checked)
{
if (columnname != a && columnname != b && columnname != c)
{
"statement 1"
}
}
else
{
if (columnname != a && columnname != b && columnname != c
&& columnname != A2)
{
"statement 1"
}
}
Example 4: if inside if c#
int Test1 = 1;
int Test2 = 1;
if (Test1 = 1)
{
if (Test2 = 1)
{
Console.WriteLine("This is the up Answer.");
}
Console.WriteLine("This is the down Answer.");
}