p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Visual C# 2012 (http://p2p.wrox.com/forumdisplay.php?f=742)
-   -   Try it out: Using a Struct: Ch05Ex03\Program.cs (Pg 91) (http://p2p.wrox.com/showthread.php?t=99204)

Tonell1618 September 27th, 2016 07:50 AM

Try it out: Using a Struct: Ch05Ex03\Program.cs (Pg 91)
 
code
.
.
.
do
{
Console.WriteLine("Select a direction:");
myDirection = Convert.ToInt32(Console.ReadLine());
}
while ((myDirection < 1) || (myDirection > 4));
/code

In code above, since we are using the OR '||' instead of the '|', shouldn't the code executes even if the user input let say '5' for e.g. Because, when using the '||', normally if the first expression is correct, the code executes, isn't it, so why here it does not act this way. I.e. if I insert '5', it would give me the 'Select a direction' again, but this should have occurred if you had use the '&&' AND operator and not the OR operator.


All times are GMT -4. The time now is 02:25 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.