Created
May 26, 2016 08:14
-
-
Save ufcpp/fe6788898ca4b91f0067dd7017af6ca4 to your computer and use it in GitHub Desktop.
false でも true でもない何か
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
using System; | |
class Program | |
{ | |
static void Main() | |
{ | |
Write(false); | |
Write(true); | |
Write(Bool(0)); // false と一緒 | |
Write(Bool(1)); // true と一緒 | |
Write(Bool(2)); // false でも true でもない何か | |
} | |
private static unsafe bool Bool(byte value) | |
{ | |
bool b = false; | |
*((byte*)&b) = value; | |
return b; | |
} | |
static void Write(bool x) | |
{ | |
switch (x) | |
{ | |
case true: | |
Console.WriteLine("True"); | |
break; | |
case false: | |
Console.WriteLine("False"); | |
break; | |
default: | |
Console.WriteLine("Other "); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment