Created
February 6, 2012 09:01
-
-
Save biac/1750914 to your computer and use it in GitHub Desktop.
C# の || と |
This file contains 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
static void Main(string[] args) { | |
if (expr1() || expr2()) | |
Console.WriteLine("|| - short circuit"); | |
if (expr1() | expr2()) | |
Console.WriteLine("| - both evaluated"); | |
Console.ReadKey(); | |
} | |
private static bool expr1() { | |
Console.WriteLine("expr1: true"); | |
return true; | |
} | |
private static bool expr2() { | |
Console.WriteLine("expr2: true"); | |
return true; | |
} | |
//出力: | |
//expr1: true | |
//|| - short circuit | |
//expr1: true | |
//expr2: true | |
//| - both evaluated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment