Skip to content

Instantly share code, notes, and snippets.

@ufcpp
Created May 26, 2016 08:14
Show Gist options
  • Save ufcpp/fe6788898ca4b91f0067dd7017af6ca4 to your computer and use it in GitHub Desktop.
Save ufcpp/fe6788898ca4b91f0067dd7017af6ca4 to your computer and use it in GitHub Desktop.
false でも true でもない何か
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