QA


Q&A

Q.

What if I want to execute code only when an expression in an if statement is false, not true? Do I need to place the code in an else clause, and no code after the if?

A.

This is where Boolean logic helps. What you need to do is make the expression evaluate to true for the code you want to run. This is accomplished using the not operator (!) in the expression, like this:

if (!expression) . . .


Q.

How important is the order in which case statements are created?

A.

This all depends on the situation. In the earlier example in which the selected animal was considered and the number of legs it has was displayed, the order of the Dog and Horse case was important. If all case statements contained code, the order has no effect.




Sams Teach Yourself Microsoft Visual C# 2005 in 24 Hours, Complete Starter Kit
Sams Teach Yourself Visual C# 2005 in 24 Hours, Complete Starter Kit
ISBN: 0672327406
EAN: 2147483647
Year: N/A
Pages: 248
Authors: James Foxall

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net