Skip to content

Instantly share code, notes, and snippets.

@luisdeol
Last active November 29, 2017 10:39
Show Gist options
  • Save luisdeol/912c00e671d7b64f589300a78c7b83c2 to your computer and use it in GitHub Desktop.
Save luisdeol/912c00e671d7b64f589300a78c7b83c2 to your computer and use it in GitHub Desktop.
Using Logical XOR and Conditional AND and OR operators
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