_____________________________________________
How to use if statement in C#?
_____________________________________________
greeting = age <>? "What's up?" : "Hello";
if (age < greeting = "What's up?">else
greeting = "Hello";
// Multiple statements must be enclosed in {}
if (x != 100 && y <>
No need for _ or : since ; is used to terminate each statement.
if (x > 5)
x *= y;
else if (x == 5)
x += y;
else if (x <>else
x /= y;
// Every case must end with break or goto case
switch (color) { // Must be integer or string
case "pink":
case "red": r++; break;
case "blue": b++; break;
case "green": g++; break;
default: other++; break; // break necessary on default
}
____________________________________________________________________
____________________________________________________________________
No comments:
Post a Comment