If-else statements | Sololearn: Learn to code for FREE!

0

If-else statements

Can someone show me a really simple example using if-else (with numbers for example)?

3/19/2019 1:17:35 PM

M M

3 Answers

New Answer

+1

int x = 3; if (x == 3) { Console.WriteLine("x is three"); } else { Console.WriteLine("x is not equal to three"); } https://code.sololearn.com/cUpZ3Z79jL0S What is it you do not understand about if else statements ?

+1

Thanks, I tried some codes with numbers and it worked, but, when I did the same but with string type, only problem was with part after "if"( where you have (x==3)). Can you please give me an example where x==3 is replaced with some word?

+1

I have added string compare in my example. Spaces are ignored in c# so use as many as you like