Last active
November 29, 2017 10:39
-
-
Save luisdeol/912c00e671d7b64f589300a78c7b83c2 to your computer and use it in GitHub Desktop.
Using Logical XOR and Conditional AND and OR operators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace implement_program_flow | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var falseValue = false; | |
| var trueValue = true; | |
| Console.WriteLine(falseValue || trueValue); | |
| Console.WriteLine(falseValue && trueValue); | |
| //Short - circuiting | |
| Console.WriteLine(trueValue || AnotherMethod()); | |
| Console.WriteLine(falseValue ^ falseValue); | |
| Console.WriteLine(falseValue ^ trueValue); | |
| Console.WriteLine(trueValue ^ falseValue); | |
| Console.WriteLine(trueValue ^ trueValue); | |
| Console.ReadLine(); | |
| } | |
| static bool AnotherMethod() | |
| { | |
| // That method will not be called because of "short-circuit" | |
| Console.WriteLine("Hey ho let's go!"); | |
| return true; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment