**IF** you are confused
read the c# spec
**ELSE IF** you are kind of confused
read some books
**ELSE**
everything should be OK.
Courtesy: https://stackoverflow.com/a/1445365/5352399
Jokes are apart, usually an if
statement follows this sort of structure:
if (condition)
{
// executed only if "condition" is true
}
else if (other condition)
{
// executed only if "condition" was false and "other condition" is true
}
else
{
// executed only if both "condition" and "other condition" were false
}
The if
portion is the only block that is absolutely mandatory. else if
allows you to say "ok, if the previous condition was not true, then if this condition is true...". The else says "if none of the conditions above were true..."
You can have multiple else if
blocks, but only one if
block and only one (or zero) else
blocks.
Answer reference: https://stackoverflow.com/a/1439915/5352399
Please read about C# control statements that will give you comprehensive idea.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…