Skip to content

Instantly share code, notes, and snippets.

@ufcpp
Created May 26, 2016 08:14
Show Gist options
  • Select an option

  • Save ufcpp/fe6788898ca4b91f0067dd7017af6ca4 to your computer and use it in GitHub Desktop.

Select an option

Save ufcpp/fe6788898ca4b91f0067dd7017af6ca4 to your computer and use it in GitHub Desktop.

Revisions

  1. ufcpp created this gist May 26, 2016.
    37 changes: 37 additions & 0 deletions NeitherTrueNorFalse.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    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;
    }
    }
    }